The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
gcc-3.4.4 build on solaris 10 failing please help mobydick UNIX for Dummies Questions & Answers 0 03-07-2008 05:04 AM
umount is failing suntac SUN Solaris 3 04-06-2007 04:45 AM
sscanf function is failing jxh461 High Level Programming 0 02-13-2007 11:10 PM
dd command failing emsecrist HP-UX 4 05-13-2005 01:39 PM
FTP login failing zbis12 UNIX for Dummies Questions & Answers 3 05-24-2002 11:01 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-29-2005
shihabvk shihabvk is offline
Registered User
  
 

Join Date: May 2005
Posts: 54
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 07:39 AM..
  #2 (permalink)  
Old 09-29-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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 (permalink)  
Old 09-30-2005
shihabvk shihabvk is offline
Registered User
  
 

Join Date: May 2005
Posts: 54
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 (permalink)  
Old 09-30-2005
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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 (permalink)  
Old 09-30-2005
shihabvk shihabvk is offline
Registered User
  
 

Join Date: May 2005
Posts: 54
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:13 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0