![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| exec Remote server? | imager | Shell Programming and Scripting | 1 | 07-23-2009 01:38 PM |
| ssh and remote command exec `uname -r` | jbmukund | Shell Programming and Scripting | 5 | 05-07-2008 07:15 PM |
| Remote Exec | TheEngineer | AIX | 1 | 05-12-2006 04:50 AM |
| remote execution | pascalbout | AIX | 2 | 01-03-2006 06:20 AM |
| exec 3 execution | snehal | UNIX for Advanced & Expert Users | 0 | 11-16-2005 08:11 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
remote execution of find -exec
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. |
|
||||
|
The one-line-remsh approach is much too complicated. There are too many issues to deal with even though it might be possible make it work eventually.
e.g. Which computer expands "*". When we match double quote characters, what characters are between the pairs of double quotes? What characters are not between double quotes? Which computer breaks the command line on seeing a semi-colon? You will be best advised to create the script on the remote server as a properly laid out readable script, and then execute the script with: Code:
remsh servername -l username -n "/pathtoscript/scriptname" |
|
||||
|
Your suggesstion is quite acceptable and i have implemented it. Thanks for your suggestion . Still the vagueness of the code haunts me and keeps me trying to debug it repeatedly.
Figuring out what exactly is happening is more than enough for me as it shall explain me shell's construct . Any other suggestions ???? |
![]() |
| Bookmarks |
| Tags |
| bash -c, find, find -exec, remsh |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|