ssh - rm failing


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ssh - rm failing
# 1  
Old 09-29-2005
ssh - rm failing

Hi,
Please help me...
I am creating a string of filenames with absolute path and deleting those files situated in the remote server using ssh .. but it doesnot work..
Can anyone help me...
here is my code


for FileName in ${myDire}
do
Tmp=`basename $FileName`
DelFiles="${DelFiles} "${SourceDirectory}/${Tmp}
done
#DelFiles contain files to be deleted with abolute path

ssh USer/Pwd@Domain echo ${DelFiles} | xargs rm

This statement gives 0 as the return value , but not deleting any of those files



Thanks in advance
Shihab

Last edited by shihabvk; 09-29-2005 at 08:39 AM..
# 2  
Old 09-29-2005
What is happening here is that your '|' is being interpreted by the local shell. This works just like rsh (read the man page for details about this.. the first few lines explain this). Try running the command escaping the '|'. i.e.
Code:
for FileName in ${myDire}
do
Tmp=`basename $FileName`
DelFiles="${DelFiles} "${SourceDirectory}/${Tmp}
done
#DelFiles contain files to be deleted with abolute path

ssh USer/Pwd@Domain echo ${DelFiles} \| xargs rm

# 3  
Old 09-30-2005
Thanks a lot blowtorch...
It worked !!!!

But a small problem..
I have to give complete path to xargs...
why is it like that ?
ssh USer/Pwd@Domain echo ${DelFiles} \| /bin/xargs /bin/rm

any idea?

Shihab
# 4  
Old 09-30-2005
If you have to supply full path, that is because the PATH variable does not have the required directories. Try running the following command:
Code:
ssh user@domain echo $PATH

Another thing, why are you doing an echo and piping the output to xargs, wont just /bin/rm ${DelFiles} do the job as well?
# 5  
Old 09-30-2005
Quote:
Originally Posted by blowtorch
If you have to supply full path, that is because the PATH variable does not have the required directories. Try running the following command:
Code:
ssh user@domain echo $PATH

The PATH is set properly
an I am able to execute the same command without absolute path from the server

Quote:
Originally Posted by blowtorch
Another thing, why are you doing an echo and piping the output to xargs, wont just /bin/rm ${DelFiles} do the job as well?
Actually why I did is , the number of arguments to rm will be more.. so it was giving error
so the final command is like this

ssh USer/Pwd@Domain echo ${DelFiles} \| /bin/xargs -n 20 /bin/rm


Shihab
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SSH is failing due to unknown reason

Hi, I have setup keys between user1@server1 and user2@server2 however, the ssh is failing. server1 is Linux 3.10.0-514.6.2.el7.x86_64 #1 SMP whereas server2 is 5.10 Generic_150400-40 sun4v sparc sun4v I have checked port 22 to be open and keys to be correct. I also find the permissions... (3 Replies)
Discussion started by: mohtashims
3 Replies

2. Shell Programming and Scripting

Ssh failing due to Bad owner error

i am logged in with "user1" on host1. I m trying to ssh to host2 using user id "user2" $ ssh user2@host2 Bad owner or permissions on /home/user1/.ssh/config Question 1: Can you please tell me why am i getting the Bad owner permissions error on that directory ? Question 2: Where is it... (7 Replies)
Discussion started by: mohtashims
7 Replies

3. Solaris

Rsync failing

Hi, I am running a rsync command from one server to another server. Source server is having user - bfdeploy and destination user is ftcjbd. Though ftcjbd is owner of /ftc/envs/static/includes/vehicles on destination server, it is still giving error "mkstemp - Permission denied". I am not able to... (4 Replies)
Discussion started by: solaris_1977
4 Replies

4. Shell Programming and Scripting

Connect (SSH) to Windows server via Linux server through a script and passing command.. but failing

I am trying to connect to Windows server via Linux server through a script and run two commands " cd and ls " But its giving me error saying " could not start the program" followed by the command name i specify e g : "cd" i am trying in this manner " ssh username@servername "cd... (5 Replies)
Discussion started by: sunil seelam
5 Replies

5. AIX

Backupios Failing

Hi Team, Please help me to resolve the below backup (backupios) issue on my VIO. My VIO is a SAN booted from EMC and powerpath has been installed on this. We already run pprootdev fix and linked the /dev/ipldevice to rootvg hdisk. ... (2 Replies)
Discussion started by: Nazar_KA
2 Replies

6. UNIX for Advanced & Expert Users

SSH public key failing without error message

My password-free ssh connection has worked in the past but has stopped working and I can't get it going again. The files in .ssh on both source and target are set to 600: drwx------ 2 ingres 1024 Mar 2 13:57 . drwxr-xr-x 25 ingres 2048 Mar 29 09:38 .. -rw------- 1 ingres ... (9 Replies)
Discussion started by: Catullus
9 Replies

7. Shell Programming and Scripting

ps -ef failing sometimes

Hi Everyone, we have a shell script "DLP_recv.sh" that has below command which is supposed to return the number of active instances of itself, which means of there is no other instance then commad would return 1 (for the current instance). The problem is that it sometimes it returns 0 which is... (3 Replies)
Discussion started by: guycool
3 Replies

8. AIX

failing drive

I posted some errpt output,see Phone Support, that this forum graciously looked at and confirmed what we suspected, that one of our RAID5 disks is failing. I have a replacement, but am having trouble downing the old disk. If I try and run Remove a Disk from smit, it says the device is busy. The... (4 Replies)
Discussion started by: markper
4 Replies

9. Shell Programming and Scripting

IF condition failing in a SSH script

Hi, I'm ssh-in to a remote machine (ubuntu) and trying to execute a little script in there.The script looks like this: ssh user@ubuntu <<EOF cd ~/test ls -l echo "Continue counting files starting with a`s ?" read answer if then ls -l a* else exit fi EOF Now everything works... (9 Replies)
Discussion started by: rubionis
9 Replies

10. HP-UX

dd command failing

I am new to HP-UX. I have an 8GB drive that is my root drive, contained in a Volume Group. I would like to clone that drive to another drive, which is 18.4GB. The other drive is not in a volume group. I am using this simple command:# dd if=/dev/dsk/c0t6d0 of=/dev/dsk/c0t5d0The command... (4 Replies)
Discussion started by: emsecrist
4 Replies
Login or Register to Ask a Question