[wplug] Bash subshell return value

Gary Morrow gary.morrow at ansys.com
Mon Aug 25 12:25:32 EDT 2003


Bob Schmertz wrote:

>Gary Morrow incurred the wrath of Bob on Aug 25, by saying
>
>  
>
>>I'm not a Bourne shell expert (I would have done it in Perl) but I see 
>>some problems:
>>
>>Wise, Jeremey wrote:
>>
>>    
>>
>>>I am trying to write a script to run a sync of two server vi scp. (no rsync
>>>is not an option as the other server guys will not load rsync:>) I have RTFM
>>>but even though I know it is some stupid user error I am not seeing the
>>>forest for the trees kind of thing.
>>>
>>>
>>>Here is the basic structure.
>>>**************
>>>#!/bin/bash
>>>#!/bin/bash
>>># Variables list
>>>Fileuplist=/root/scpcopyup.list
>>>Filedownlist=/root/scpcopydown.list
>>>FilesSynced=/root/filesynced.list
>>>
>>># SCP Up to IDX
>>>while [ -s $Fileuplist ]
>>>       do
>>># file ./root/firstline.pl is a perl script which cuts the first line out of
>>>a file checks if it is a directory
>>># if not directory sends it to standard out. EX: firstline.pl /root/scpcopyup.list -> ./etc/fstab. (first line)     
>>>
>>>Currentfile=(/root/firstline.pl $Fileuplist)
>>>
>>>      
>>>
>>It's not parens, it's backtics. You need:
>>
>>Currentfile=`/root/firstline.pl $Fileuplist`
>>    
>>
>
>Since this is bash, he can also use $(/root/firstline.pl $Fileuplist).  
>Prehaps he was reading the manual but missed the need for the $.
>

According to O'Reilly's "UNIX in a Nutshell" the $( ) thing is a Korn 
Shell thing. I guess BASH is a hybred. Live and learn.
BTW, I would recommend the Nutshell book as an excellent reference.


-- 
		     	
Gary Morrow                
Integ. Testing Grp.   
Ansys Inc.            
gary.morrow at ansys.com 
724-514-2978          





More information about the wplug mailing list