11-05-2009
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.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi everybody,
sorry if the question will be too trivial for some of you, but I'm not a unix shell programmer expert.
I need to write a script that allows me to rlogin to another machine, check the load (cpu and mem usage) of the new machine, start a process (that will run in the background) and... (5 Replies)
Discussion started by: ragmelo
5 Replies
2. UNIX for Advanced & Expert Users
Dear All,
while opening new subscript file using "exec 3> $3" say for e.g.
for some condition output is to be redirected to third argument passed.
I am getting error exec not found .
I think new subscript redirection file not getting opened.
Plz help me out.
Snehal \\ (0 Replies)
Discussion started by: snehal
0 Replies
3. AIX
good morning
I would like copy and execute a shell script on a remote server
telnet is not autorize, so i use ssh:
scp to copy and ssh to execute
But with the scp, the permissions are not saved and the file 's permission on the remote server is r--r--r-- , so i can't execute it
Can you help... (2 Replies)
Discussion started by: pascalbout
2 Replies
4. AIX
Dears
we have an application that try to excute commands via using a (rexec.dll) to connect to an AIX box and running commnds but when we try to do that then the connection will be rejected by the AIX box, are there any pre-configurations or settings that must be done in order to gain the... (1 Reply)
Discussion started by: TheEngineer
1 Replies
5. Shell Programming and Scripting
Hi guys,
I am trying to do a ssh for performing a set of actions.
Find it below:
I need to put the user/ kernel/ DISTRO variables before I complete this operation.
what I observed is when ever I put a `command` in those quotes, it performs thta action in local system rather than remote one.... (5 Replies)
Discussion started by: jbmukund
5 Replies
6. Shell Programming and Scripting
We have multiple Unix servers and a particular command can only be executed in one of the box from a specific path. I have password-less ssh set up for all the boxes. I am unsure the command to use to execute that particular command from any other box. To be specific say program named _my_exe_ can... (4 Replies)
Discussion started by: uunniixx
4 Replies
7. Shell Programming and Scripting
I use this code to remove old backupfiles on the local system.
exec('/usr/bin/sudo find /backup/daily-con* -mtime +7 -exec rm {} \;')
I would also like to run this command on a remote system that is on the same network. (192.168.1.50)
My question is can this be done and if so how.
... (1 Reply)
Discussion started by: imager
1 Replies
8. UNIX for Dummies Questions & Answers
Hello, I'm new to scripting so, sorry if this is a dumb question. What's the best way to execute a .sh file remotely? I want to log into server "b" from server "a" & run a script. "./scriptname.sh". At this point, all I'm looking to do is a simple ls -la > output.txt within the script to capture... (3 Replies)
Discussion started by: crunch10c
3 Replies
9. Shell Programming and Scripting
Hi Friends,
Please help me to sort out this problem, I am running this in centos o/s and whenever I run this script I am getting "find: missing argument to `-exec' " but when I run the same code in the command line I didn't find any problem. I am using perl script to run this ... (2 Replies)
Discussion started by: ramkumarselvam
2 Replies
10. Shell Programming and Scripting
Hi,
Given addresses of 2 remote machines, using a shell script is it possible to
get the state of running processes in "src"
stop all the processes in "src"
exit out of "src"
ssh into "dest"
resume the state of executing processes captured in step 1 in "dest"
Assumption:
"src" is... (3 Replies)
Discussion started by: Saeya Darsan
3 Replies
LEARN ABOUT SUSE
sieveshell
SIEVESHELL(1) User Contributed Perl Documentation SIEVESHELL(1)
NAME
sieveshell - remotely manipulate sieve scripts
SYNOPSIS
sieveshell [--user=user] [--authname=authname] [--realm=realm] [--exec=script] server[:port]
sieveshell --help
DESCRIPTION
sieveshell allows users to manipulate their scripts on a remote server. It works via MANAGESIEVE, a work in progress.
The following commands are recognized:
list list scripts on server.
put <filename> upload script to server.
get <name> [<filename>] get script. if no filename display to stdout
delete <name> delete script.
activate <name> activate script.
deactivate deactivate all scripts.
OPTIONS
-u user, --user=user
The authorization name to request; by default, derived from the authentication credentials.
-a authname, --authname=authname
The user to use for authentication (defaults to current user).
-r realm, --realm=realm
The realm to attempt authentication in.
-e script, --exec=script
Instead of working interactively, run commands from script, and exit when done.
REFERENCES
[MANAGESIEVE] Martin, T.; "A Protocol for Remotely Managing Sieve Scripts", draft-ietf-managesieve-03.txt, Mirapoint, Inc.; May 2001, work
in progress.
AUTHOR
Tim Martin <tmartin@mirapoint.com>, and the rest of the Cyrus team <cyrus-bugs@andrew.cmu.edu>.
perl v5.10.0 2008-04-04 SIEVESHELL(1)