Re: Bash script problem

2021-08-06 Thread Gregory Seidman

Re: Bash script problem

2021-08-06 Thread tomas
On Fri, Aug 06, 2021 at 07:52:20AM -0700, Gary L. Roach wrote: > > On 8/5/21 1:15 PM, Greg Wooledge wrote: [...] > >>You're doing *way* too much work. It's a gigantic X-Y problem. > I agree. I'm going back through the code and rewriting most of it. OTOH... this is how most learning journeys st

Re: Bash script problem

2021-08-06 Thread Gary L. Roach
On 8/5/21 1:15 PM, Greg Wooledge wrote: On Thu, Aug 05, 2021 at 01:03:16PM -0700, Gary L. Roach wrote: First, the IFS command sets the string separator. The default values are space /n and one other. The / is not among them. Yes, we know that. The issue is that you are setting IFS for the wh

Re: Bash script problem

2021-08-06 Thread Darac Marjal
On 06/08/2021 00:30, David wrote: > On Fri, 6 Aug 2021 at 06:03, Gary L. Roach wrote: > >> Second, why am I separating out the Path the way I am doing? I need to >> check each level for existence then, if the level doesn't exist, create >> the directory, cd to the directory, set chown and -x chmo

Re: Bash script problem

2021-08-05 Thread tomas
On Fri, Aug 06, 2021 at 10:52:51AM +1000, David wrote: [...] > I was commenting on how I have always been puzzled why > someone made the effort to give 'chmod' an '-R' option, but > never made it actually useful for common cases. As it is, > it seems that it's really only useful for modifying the

Re: Bash script problem

2021-08-05 Thread David
On Fri, 6 Aug 2021 at 13:06, David Wright wrote: > On Fri 06 Aug 2021 at 09:30:17 (+1000), David wrote: > > 'chmod -R' is less useful because it does not discriminate > > between files and directories, I never understood why it > > does not offer that option, because usually we need all file > >

Re: Bash script problem

2021-08-05 Thread David Wright
On Fri 06 Aug 2021 at 09:30:17 (+1000), David wrote: > On Fri, 6 Aug 2021 at 06:03, Gary L. Roach wrote: > > > Second, why am I separating out the Path the way I am doing? I need to > > check each level for existence then, if the level doesn't exist, create > > the directory, cd to the directory,

Re: Bash script problem

2021-08-05 Thread Greg Wooledge
On Thu, Aug 05, 2021 at 09:47:04PM -0400, The Wanderer wrote: > I believe I've hit contexts in which I could use '-print0 | xargs -0' > but couldn't figure out a way to get the job done with '-exec', because > I needed the command which was being run to process the output to be a > pipeline. (I no

Re: Bash script problem

2021-08-05 Thread The Wanderer
On 2021-08-05 at 20:25, Greg Wooledge wrote: >> >> find . -type d -exec chmod -v 0644 '{}' \; > >> > Use + instead of \; to make them more efficient. > >> What does + make as a difference ? > > It's a replacement for xargs, except that it actually works, unlike > xargs, which is horribly broken

Re: Bash script problem

2021-08-05 Thread David
On Fri, 6 Aug 2021 at 10:58, Christian Groessler wrote: > On 8/6/21 2:52 AM, David wrote: > > I was commenting on how I have always been puzzled why > > someone made the effort to give 'chmod' an '-R' option, but > > never made it actually useful for common cases. As it is, > > it seems that it's

Re: Bash script problem

2021-08-05 Thread Greg Wooledge
On Fri, Aug 06, 2021 at 02:58:00AM +0200, Christian Groessler wrote: > On 8/6/21 2:52 AM, David wrote: > > I was commenting on how I have always been puzzled why > > someone made the effort to give 'chmod' an '-R' option, but > > never made it actually useful for common cases. As it is, > > it seem

Re: Bash script problem

2021-08-05 Thread Christian Groessler
On 8/6/21 2:52 AM, David wrote: I was commenting on how I have always been puzzled why someone made the effort to give 'chmod' an '-R' option, but never made it actually useful for common cases. As it is, it seems that it's really only useful for modifying the write attribute. Hmm. "chmod -R go

Re: Bash script problem

2021-08-05 Thread David
On Fri, 6 Aug 2021 at 10:01, Polyna-Maude Racicot-Summerside wrote: > On 2021-08-05 7:30 p.m., David wrote: > > On Fri, 6 Aug 2021 at 06:03, Gary L. Roach wrote: > > 'chmod -R' is less useful because it does not discriminate > > between files and directories, I never understood why it > > does n

Re: Bash script problem

2021-08-05 Thread Christian Groessler
On 8/6/21 2:01 AM, Polyna-Maude Racicot-Summerside wrote: find . -type d -exec chmod -v 0644 '{}' \; to change the folder find . -type f -exec chmod -v 0755 '{}' \; to change files Pah. Use 'xargs' :-) $ find . -type f -print0 | xargs -0 chmod 644 $ find . -type d -print0 | xargs -0 chmod

Re: Bash script problem

2021-08-05 Thread Greg Wooledge
> >> find . -type d -exec chmod -v 0644 '{}' \; > > Use + instead of \; to make them more efficient. > What does + make as a difference ? It's a replacement for xargs, except that it actually works, unlike xargs, which is horribly broken without GNU extensions. find . -type d -exec chmod 755 {}

Re: Bash script problem

2021-08-05 Thread Polyna-Maude Racicot-Summerside
Hi, On 2021-08-05 8:07 p.m., Greg Wooledge wrote: > On Thu, Aug 05, 2021 at 08:01:22PM -0400, Polyna-Maude Racicot-Summerside > wrote: >> find . -type d -exec chmod -v 0644 '{}' \; >> >> to change the folder >> >> find . -type f -exec chmod -v 0755 '{}' \; >> >> to change files > > You've switch

Re: Bash script problem

2021-08-05 Thread Greg Wooledge
On Thu, Aug 05, 2021 at 08:01:22PM -0400, Polyna-Maude Racicot-Summerside wrote: > find . -type d -exec chmod -v 0644 '{}' \; > > to change the folder > > find . -type f -exec chmod -v 0755 '{}' \; > > to change files You've switched the permissions around. You want 644 on the files, and 755 o

Re: Bash script problem

2021-08-05 Thread Polyna-Maude Racicot-Summerside
Hi, On 2021-08-05 7:30 p.m., David wrote: > On Fri, 6 Aug 2021 at 06:03, Gary L. Roach wrote: > >> Second, why am I separating out the Path the way I am doing? I need to >> check each level for existence then, if the level doesn't exist, create >> the directory, cd to the directory, set chown an

Re: Bash script problem

2021-08-05 Thread David
On Fri, 6 Aug 2021 at 06:03, Gary L. Roach wrote: > Second, why am I separating out the Path the way I am doing? I need to > check each level for existence then, if the level doesn't exist, create > the directory, cd to the directory, set chown and -x chmod. After that > check the next level and

Re: Bash script problem

2021-08-05 Thread Tom Browder
On Wed, Aug 4, 2021 at 18:58 Gary L. Roach wrote: > Hi all; > I have just recently delved into the magical world of Bash scripting and I long ago gave up bash scripting for other than simple scripts, even for sysadmin chores. Most Linux distros, including our favorite Debian, come with Perl in

Re: Bash script problem

2021-08-05 Thread Greg Wooledge
On Thu, Aug 05, 2021 at 01:03:16PM -0700, Gary L. Roach wrote: > First, the IFS command sets the string separator. The default values are > space /n and one other. The / is not among them. Yes, we know that. The issue is that you are setting IFS for the whole script, when you probably *should* be

Re: Bash script problem

2021-08-05 Thread Gary L. Roach
hi all; I really appreciate all of your help. The file now works. See attached. Now t0 answer some questions. First, the IFS command sets the string separator. The default values are space /n and one other. The / is not among them. If I don't set the delimiter before I do the read, the whol

Re: Bash script problem

2021-08-05 Thread Greg Wooledge
On Wed, Aug 04, 2021 at 08:47:30PM -0700, Gary L. Roach wrote: > Thanks for the help but I still have the problem of the if statement always > being true. This time I enclosed the file so you can test it. You didn't make the changes that I told you to make yesterday. But this has already been cov

Re: Bash script problem

2021-08-05 Thread Greg Wooledge
On Thu, Aug 05, 2021 at 10:38:47AM +0200, to...@tuxteam.de wrote: > On Thu, Aug 05, 2021 at 09:26:35AM +0100, Tixy wrote: > > ; has no special meaning inside "". The expression is true because > > there is only a single non-null argument between the [ ] Precisely. But you're probably not explaini

Re: Bash script problem

2021-08-05 Thread Greg Wooledge
On Thu, Aug 05, 2021 at 10:07:12AM +0200, to...@tuxteam.de wrote: > [1] Nowadays this is a little white lie: most shells have them >as builtins, but they are supposed to behave like regular >programs, for compat. There /is/ a /bin/test, but I can't >find a /bin/[ on my system anymore.

Re: Bash script problem

2021-08-05 Thread tomas
On Thu, Aug 05, 2021 at 09:26:35AM +0100, Tixy wrote: > On Thu, 2021-08-05 at 10:36 +0300, Anssi Saari wrote: > [...] > > > > [ A="0 ; " ] > > > > is always true. It seems it probably has something to do with expansion, > > quoting and the special meaning of ;. > > > > ; has no special meaning

Re: Bash script problem

2021-08-05 Thread Tixy
On Thu, 2021-08-05 at 10:36 +0300, Anssi Saari wrote: [...] > > [ A="0 ; " ] > > is always true. It seems it probably has something to do with expansion, > quoting and the special meaning of ;. > ; has no special meaning inside "". The expression is true because there is only a single non-null

Re: Bash script problem

2021-08-05 Thread tomas
On Wed, Aug 04, 2021 at 08:47:30PM -0700, Gary L. Roach wrote: > Thanks for the help but I still have the problem of the if statement > always being true. This time I enclosed the file so you can test it. Please, don't top quote. It confuses the hell out of me. Now, I think in your script if t

Re: Bash script problem

2021-08-05 Thread Anssi Saari
"Gary L. Roach" writes: > Hi all; > > I have just recently delved into the magical world of Bash scripting > and programmed up the following script(not finished). The object is to > parse the Path and check for the existence of each directory. Please > don't send back an Awk or Sed statement that

Re: Bash script problem

2021-08-04 Thread john doe
On 8/5/2021 5:47 AM, Gary L. Roach wrote: Thanks for the help but I still have the problem of the if statement always being true. This time I enclosed the file so you can test it. Two things: - Why is the var 'IFS' set above the read command? - What are you trying to do here? -- John Doe

Re: Bash script problem

2021-08-04 Thread Gary L. Roach
Thanks for the help but I still have the problem of the if statement always being true. This time I enclosed the file so you can test it. Gary R On 8/4/21 5:04 PM, Greg Wooledge wrote: On Wed, Aug 04, 2021 at 04:58:00PM -0700, Gary L. Roach wrote: Path="/Test/gary/run/something" IFS=/ read -a

Re: Bash script problem

2021-08-04 Thread Greg Wooledge
On Wed, Aug 04, 2021 at 04:58:00PM -0700, Gary L. Roach wrote: > Path="/Test/gary/run/something" > IFS=/ > read -a Array <<< $Path You're setting IFS permanently for the whole script. It's usually better to set it only for the duration of the single read command which uses it. Also, read should

Re: Bash script problem [OT?]

2012-04-25 Thread Chris Davies
Cam Hutchison wrote: > Sigh. Sorry, it was a typo. That explains why it did not work for the OP. Phew! These array things are new to me in a shell context - I've used associative and indexed arrays for years in awk and perl, though - and after your example didn't work I went digging through the

Re: Bash script problem [OT?]

2012-04-24 Thread Cam Hutchison
Chris Davies writes: >Cam Hutchison wrote: >> BK_LIST=() >> Append to the array with += >> BK_LIST+="${PARAM}" >This += syntax appears not to work with my version of bash >("4.1.5(1)-release" from package bash 4.1-3). Instead I have >to do this: > BK_LIST+=("${PARAM}") >Was yours a typo, o

Re: Bash script problem [OT?]

2012-04-24 Thread Chris Davies
Cam Hutchison wrote: > BK_LIST=() > Append to the array with += > BK_LIST+="${PARAM}" This += syntax appears not to work with my version of bash ("4.1.5(1)-release" from package bash 4.1-3). Instead I have to do this: BK_LIST+=("${PARAM}") Was yours a typo, or is it something that now works

Re: Bash script problem [OT?]

2012-04-23 Thread Dan B.
I wrote: ... FILES_LIST=( "${FILES_LIST[@]}" "${NEW_FILE}" ) You can also write: FILE_LIST[${#FILE_LIST[@]}]="${NEW_FILE}" Daniel -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive:

Re: Bash script problem [OT?]

2012-04-23 Thread Cam Hutchison
Soare Catalin writes: >Thank you everyone for replying, but unfortunately, nothing seems to work >for the moment, although all the answers appear to make sense. >First, the array solution appears to work, but when tar gets all the >parameters, they become a long string without spaces :), obviousl

Re: Bash script problem [OT?]

2012-04-23 Thread Dan B.
Iuri Guilherme dos Santos Martins wrote: When dealing with paths in bash i usually employ two things: One is declaring arrays like this: FILES_LIST=( ) And everytime I want to append to the array I go like this: FILES_LIST=( ${FILES_LIST[@]} ${NEW_FILE} ) Obviously I will have problems if th

Re: Bash script problem [OT?]

2012-04-23 Thread Iuri Guilherme dos Santos Martins
When dealing with paths in bash i usually employ two things: One is declaring arrays like this: FILES_LIST=( ) And everytime I want to append to the array I go like this: FILES_LIST=( ${FILES_LIST[@]} ${NEW_FILE} ) Obviously I will have problems if the paths or files have spaces in their nam

Re: Bash script problem [OT?]

2012-04-22 Thread Dom
On 22/04/12 22:02, Soare Catalin wrote: On Sun, Apr 22, 2012 at 10:25 PM, Dom wrote: On 22/04/12 08:34, Cam Hutchison wrote: Soare Catalin> writes: The script will take files or dirs as parameters and will back them up in a presefined location, using tar. Problems arise when it will en

Re: Bash script problem [OT?]

2012-04-22 Thread Soare Catalin
On Sun, Apr 22, 2012 at 10:25 PM, Dom wrote: > On 22/04/12 08:34, Cam Hutchison wrote: > >> Soare Catalin> >> writes: >> >> The script will take files or dirs as parameters and will back them up >>> in a >>> presefined location, using tar. Problems arise when it will encounter >>> files >>> or

Re: Bash script problem [OT?]

2012-04-22 Thread Dom
On 22/04/12 08:34, Cam Hutchison wrote: Soare Catalin writes: The script will take files or dirs as parameters and will back them up in a presefined location, using tar. Problems arise when it will encounter files or directories which contain spaces in their names. then #is it an existing d

Re: Bash script problem [OT?]

2012-04-22 Thread Cam Hutchison
Soare Catalin writes: >The script will take files or dirs as parameters and will back them up in a >presefined location, using tar. Problems arise when it will encounter files >or directories which contain spaces in their names. >then #is it an existing directory? >BK_LIST="$BK_LIST ${PARAM}" h

Re: Bash script problem [OT?]

2012-04-21 Thread emmanuel segura
Scusa ho svagliato BK_FULLPATH="${BK_LOCATION}BACKUP_${DATETIME}.tar.bz2" tar -cjf "$BK_FULLPATH" "$BK_LIST" Il giorno 21 aprile 2012 10:07, Soare Catalin ha scritto: > Hello fellow Linux supporters! > > I apologise if this specific thread is off topic to this mailing list. > > I've been having

Re: Bash script problem [OT?]

2012-04-21 Thread emmanuel segura
BK_FULLPATH="${BK_LOCATION}/BACKUP_${DATETIME}.tar.bz2" tar -cjf "$BK_FULLPATH" "$BK_LIST" Il giorno 21 aprile 2012 10:07, Soare Catalin ha scritto: > Hello fellow Linux supporters! > > I apologise if this specific thread is off topic to this mailing list. > > I've been having problems with a b

Re: Bash script problem

2005-05-17 Thread Almut Behrens
On Tue, May 17, 2005 at 02:29:41PM +0200, [EMAIL PROTECTED] wrote: > I have a problem with a bash script. The script (example) is very simple: > > script.sh--- > #!/bin/bash > > echo hello > ssh PT-AGCMLX1 "while true; do date; sleep 10s; done" > -

Re: Bash script problem

2005-05-17 Thread Markus . Grunwald
Hello, > > I have a problem with a bash script. The script (example) is very simple: > > > > #!/bin/bash > > > > echo hello > > ssh PT-AGCMLX1 "while true; do date; sleep 10s; done" > [..] > > How can I change my script so that it kills all its child processes, if it > > is killed itself

Re: Bash script problem

2005-05-17 Thread Dennis Stosberg
Am 17.05.2005 um 11:50 schrieb [EMAIL PROTECTED]: > I have a problem with a bash script. The script (example) is very simple: > > #!/bin/bash > > echo hello > ssh PT-AGCMLX1 "while true; do date; sleep 10s; done" [..] > How can I change my script so that it kills all its child processes, if it