Hi folks
I am working on a script which lists files of a specific pattern on a remote m/c and tar&zip them to another remote m/c via a centralized server.
M/C details:
remote1 - OSF1 vayu V5.1 2650 alpha
remote2 - cygwin based windows server
central - SunOS phys-chenab 5.8 Generic_117350-61 sun4u sparc SUNW,Sun-Fire-15000
LAYOUT
*******
remote1(vayu) -------> central (chenab) ----------> remote2 (cygwin windows)
Have a issue with the script which seriously retards me . The logic is to check if a particular file has already been transferred , and if not transfer the same . This checking happens at the remote side through remsh. This part works well when executed directly on remote1 but fails when executed from central server.
set -f;cd /usr1/smscomn/data/cards/spool/ ;find /usr1/smscomn/data/cards/spool/ -name "CS507.11.[0-9]*.47.*" -exec bash -c ' grep $0 /usr1/smscomn/data/cards/status_vayu | grep success ; if [ `echo $?` -eq 0 ] ;then printf "$0 copied \n" ; else printf " $0 transferred already \n" ; fi ' {} {} \; ;set +f
remsh vayu "set -f;cd /usr1/smscomn/data/cards/spool/ ; find /usr1/smscomn/data/cards/spool/ -name "CS507.11.[0-9]*.47.*" -exec bash -c ' grep $0 /usr1/smscomn/data/cards/status_vayu | grep success ; if [ `echo $?` -eq 0 ] ;then printf " copied"; echo $0 ; else printf $0 transferred ; fi ' {} {} \; ;set +f "
Output:
copiedbash
copiedbash
copiedbash
copiedbash
$0 parameter of bash -c should be filename output of find but why is it pointing to prog name which is bash .
Moreover when i change bash -c to sh -c , i expect output to be "copiedsh" ; but its still "copiedbash"
Can you please provide some light on whats happening? . I am open to corrections and suggestions and even harsh rebuke over insanity of the code.