Perl system ssh find question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl system ssh find question
# 1  
Old 07-19-2006
Perl system ssh find question

I have the following perl code that I use to run backups on remote machines. No problems here, the code works without problems
Code:
system "ssh", $SHORT_NAME, "cd /;", "sudo", "tar", "cvf", "-", "--exclude=/dev", "--exclude=/proc",  "/|", "netcat", "-w2", "troll", "2011" ;

The code is used for full backups once a week but I want to modify if to do partial backups every 3 days.
I have come up with the following code
Code:
system "ssh", $SHORT_NAME, "cd /;", "pwd;", "sudo", "find", "/", "\(", "-wholename", "/dev/*", "-o", "-wholename", "/proc/*", "\)", "-pru
ne", "-o", "-print", "-type f", "-mtime -3;", "|", "tar", "cvf", "-", "/|", "netcat", "-w2", "troll", "2011" ;

but I get the error message "bash: -c: line 1: syntax error near unexpected token `(' " .
Thinking that there is a problem with "/(" I modifiied it to "\", "(", and "\", ")", which gives me the error message
"String found where operator expected at ./pl-backup line 84, near "wholename", ""
Unquoted string "dev" may clash with future reserved word at ./pl-backup line 84. "

Anyone able to help me with this?
# 2  
Old 07-19-2006
if the actual command you want to run has a \ in it ( for example where you actually want \(, you need to escape it and put in \\( instead.
# 3  
Old 07-19-2006
simple test
Code:
$ perl -e 'system "echo", "\("'
(
$ perl -e 'system "echo", "\\("'
\(

# 4  
Old 07-19-2006
Quote:
Originally Posted by reborg
if the actual command you want to run has a \ in it ( for example where you actually want \(, you need to escape it and put in \\( instead.
Thanks reborg. Escaping the \ worked.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find active SSH servers w/ ssh keys on LAN

Hi, I am trying to complete my bash script in order to find which SSH servers on LAN are still active with the ssh keys, but i am frozen at this step: #!/bin/bash # LAN SSH KEYS DISCOVERY SCRIPT </etc/passwd \ grep /bin/bash | cut -d: -f6 | sudo xargs -i -- sh -c ' && cat... (11 Replies)
Discussion started by: syrius
11 Replies

2. Shell Programming and Scripting

Perl SSH without a perl module

I'm trying to create a perl script that will do 1 SSH session, but be able to write multiple commands to the session and receive multiple outputs. I know there are modules out there like Net:SSH::Perl, but I'm not allowed to use it. I was thinking of doing something like an open3 on an ssh... (4 Replies)
Discussion started by: mrwatkin
4 Replies

3. Shell Programming and Scripting

find: missing argument to `-exec' while redirecting using find in perl

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

4. Shell Programming and Scripting

Send "perl -e '...' " command through SSH, from a perl script

Hey guys I am trying to send a perl -e command to a number of systems using SSH. The command should retrieve some information for me. The problem is, the remote shell tries to interpolate my variables and doesn't get it should take the command literally and just execute it. Below the code.... (2 Replies)
Discussion started by: clrg
2 Replies

5. Shell Programming and Scripting

Regarding ssh into remote system

How can i ssh into a remote system using ssh command in a shell script with password? I havent used password less authentication for the remote system. Thanks and Regards, Rupaa (4 Replies)
Discussion started by: Rupaa
4 Replies

6. Shell Programming and Scripting

Executing a script on a remote system via SSH

Hello all, I have a relatively simple script I wrote to generate a count of errors broken down. What I would like to do is execute this script from another server so that I don't actually have to log in to the server to run the check. The script on what we'll call "Server A" is: ... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

7. Shell Programming and Scripting

ssh on system

hello i am using sshpass to pass the password when trying to ssh to another system with script it works like that sshpass -p 'm7843jdf' ssh -o StrictHostKeyChecking=no serverXY the problem i wants to run application commands after i login like the following cd /opt/monitor/roco... (4 Replies)
Discussion started by: mogabr
4 Replies

8. Shell Programming and Scripting

How to find pid of PS which executed by perl system function

hello All, I need to invoke by perl script some program/command and monitor it for 5 minutes . In case it still running for more then 5 min I need to send a signal which will stop it. I implemeted this as shown below by using eval & alarm and I'd like to know if there is a better way to... (1 Reply)
Discussion started by: Alalush
1 Replies

9. Solaris

Secure FTP Problem using Sun SSH on Client system F-Secure on Server system

I am using shell script to do secure ftp. I have done key file setup to do password less authentication. Following are the FTP Details: FTP Client has Sun SSH. FTP Server has F-Secure. I am using SCP Command to do secure copy files. When I am doing this, I am getting the foll error scp:... (2 Replies)
Discussion started by: ftpguy
2 Replies

10. Shell Programming and Scripting

Running ssh on a remote system?

I need to install ypbind and yp-tools on over two-hundred remote client machines based on their redhat version. I have a centralized server on which I created an ssh public key. I then transfered the ssh public key to the authorized_keys file on all the remote hosts; therefore, I can login without... (1 Reply)
Discussion started by: cstovall
1 Replies
Login or Register to Ask a Question