Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

FTP rename command help

UNIX for Dummies Questions & Answers


 
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 05-27-2016
srikanth38 srikanth38 is offline
Registered User
 
Join Date: Oct 2008
Last Activity: 8 August 2017, 5:15 PM EDT
Posts: 28
Thanks: 11
Thanked 3 Times in 3 Posts
FTP rename command help

I have to ftp and rename the file with #finished# extension after successfully transfer. In some environments the command
Code:
rename ABCD.dat ABCD.#finished#

is working fine, but some environments its not working, I have to use escape character something like :
Code:
rename ABCD.dat ABCD.\#finished\#

Why is it behaving differently? Both servers are running on Linux same version and korn shell.

Thank you in advance for your help.
Sponsored Links
    #2  
Old Unix and Linux 05-28-2016
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 20 October 2017, 2:22 PM EDT
Location: Aachen, Germany
Posts: 11,479
Thanks: 310
Thanked 3,561 Times in 3,276 Posts
rename is neither a linux nor a ksh command/builtin. It's either an ftp command or a perl script. Compare the versions of either.
Sponsored Links
    #3  
Old Unix and Linux 05-29-2016
srikanth38 srikanth38 is offline
Registered User
 
Join Date: Oct 2008
Last Activity: 8 August 2017, 5:15 PM EDT
Posts: 28
Thanks: 11
Thanked 3 Times in 3 Posts
Quote:
Originally Posted by RudiC View Post
rename is neither a linux nor a ksh command/builtin. It's either an ftp command or a perl script. Compare the versions of either.

Thanks for your reply, Rename is a ftp command. I already compared the versions, it seems fine. Would like to understand why it is behaving differently.
    #4  
Old Unix and Linux 05-29-2016
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
 
Join Date: Feb 2004
Last Activity: 20 October 2017, 11:27 AM EDT
Location: NM
Posts: 11,215
Thanks: 567
Thanked 1,110 Times in 1,024 Posts
I suspect the difference arises from the remote ftp code's rename command being implemented two different ways on the remote servers:

system 1
call the equivalent of C:
Code:
system ("mv oldfilename newfilename")

This would mean invoking the /bin/sh shell on the remote machine, which in turn would see a '#' character as a comment, which requires your escape "\" fix.

system 2
call the mv syscall or the C standard library's rename library call - this never invokes /bin/sh so no shell is called.

Note: /bin/sh can be a completely different object on different machines - it is NOT necessarily the shell that you use to run the ftp script locally.
The Following User Says Thank You to jim mcnamara For This Useful Post:
srikanth38 (05-30-2016)
Sponsored Links
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
[Solved] Unable to rename file in ftp server .Net:FTP perl krsnadasa HP-UX 2 12-02-2011 07:45 AM
how to rename all the files with one command? filthymonk Shell Programming and Scripting 2 07-03-2008 04:04 AM
rename files in remote server via ftp dineshr85 Shell Programming and Scripting 4 02-20-2008 11:30 AM
rename while doing ftp Nagabhushan Shell Programming and Scripting 1 08-28-2007 05:54 AM
how to rename a file before and after a ftp? forevercalz Shell Programming and Scripting 2 10-28-2005 09:19 AM



All times are GMT -4. The time now is 04:03 PM.