[wplug] Bash subshell return value
Wise, Jeremey
WISEJ at PIOS.com
Mon Aug 25 10:29:55 EDT 2003
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)
# test of variable output
echo $Currentfile
rc=$?
if [ $rc -ne 0 ] ; then
printf "Error reading file"
exit 50
else
scp user at acme.com:/$Currentfile .
if [ $rc -ne 0 ] ; then
echo "$Currentfile failed to copy up." >> $FileSynced
exit 51
else
echo "$Currentfile successfully copied." >> $FilesSynced
fi
fi
done
# SCP Down to ACME.com
.....
****************
The out put is as follows
[root at toybox root]# ./test.scp
/root/firstline.pl
**************
Yet, if I run the command directly the correct output is replied:
[root at toybox root]# ./firstline.pl /root/scpcopyup.list
/etc/lilo.conf.anaconda[root at toybox root]#
*****************
I thought using () quotes would run the command in the quotes in a subshell
and simply return results? I have tried (( ...)) which should again run
(ignoring variables set so I replaced with explicit paths to variables) and
this had no effect
Any help would be appreciated.
Thanks,
Jeremey Wise (440)-519-6006
(CNE,MCSE,CSE)
Pioneer-Standard Electronics, Inc
wisej at pios.com
IBM ED PACK -Part # SB033 $4,500 ... SP Discount 11%
IBM ED CARD - Part # SB218 $8,995 ... SP Discount 8.5%
More information about the wplug
mailing list