473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to move files from one folder to another folder with sftp Perl

I have files in ToTransfer folder on remote windows server. I need to move them to ToTransfre\Transferred folder. I am using sftp. The code below did not give me compile error but it did not work either. Can anyone please let know how to get it working?

Expand|Select|Wrap|Line Numbers
  1. unless(move("ToTransfer\\$filelist[$li]->{filename}", "ToTransfer\\Transferred"))
  2.             {
  3.              print "Couldn't move the file to directory ToTransfer\\Transferred\n";
  4.             }
  5.  
Dec 29 '11 #1
5 4335
numberwhun
3,509 Expert Mod 2GB
The $! variable holds the error from the last executed command. Try making the print line like this and see if it gives you more information:

Expand|Select|Wrap|Line Numbers
  1. print "Couldn't move the file to directory ToTransfer\\Transferred:   $!\n";
  2.  
If it spits out an error after the :, then see if you can figure out why it isn't working.

Regards,

Jeff
Jan 2 '12 #2
I added the $! into the print line. I had "No such file or directory". I double-checked the file name and directory. I did not find anything wrong. I tried to use $sftp->move command to move the file. But I get "Can't locate object method "move" via package "Net::SFTP"". I am wondering if sftp can support the move?
Jan 2 '12 #3
RonB
589 Expert Mod 512MB
Why are you using Net::SFTP for moving files on a remote system?

While it's probably possible to do the move with that module, it's not the proper module for that task. It would be better to use Net::SSH or Net::SSH::Perl.
Jan 2 '12 #4
numberwhun
3,509 Expert Mod 2GB
I definitely agree with @RonB. The Net:SFTP module is for transferring files between your machine and a remote machine, and vice versa, not managing where things are on the remote mating. Take a look at the Net::SSH module that @RonB suggested as its much better suited to the task. You connect to the remote system and then do what you need to do from within your Perl code.
Jan 3 '12 #5
thanks to both of you: numberwhun and RonB.
Jan 3 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Stein | last post by:
I've seen a couple postings on moving files to folders with set source and destination paths, but I still need a little help taking it a step further. I have a folder with 2,000 Word docs that I...
0
by: patricia | last post by:
Hi all, I got a problem with my web application. I have a project under the inetpub/wwwroot. Now I move it to another folder under c:\. There is a subfolder in this project. when I run the web...
5
by: lwoods | last post by:
This should be simple, but I can't figure out an easy way...without recreating the complete project. I have a project in one folder, and I want to move the complete project into another folder....
3
by: neilmcguigan | last post by:
is there a way to get visual studio (2k3) to put and keep resx files in a folder? i create yada.aspx yada.aspx.resx is created i move yada.aspx.resx to folder deda next time i start VS, there...
2
by: jonathan184 | last post by:
how to move one file at a time to another folder. I am trying to one file at a time for every 30 minutes. So far the script is transferring all files at the same time and the source folder...
3
by: =?Utf-8?B?UHVyZSBIZWFydA==?= | last post by:
hi i need the code to move files from directory to another directory on sam local machine or to a network path, thank you. -- Ammar S. Mitoori IT Head QIMCO Co. Tel : +9744831199 Mobile :...
3
by: jaeden99 | last post by:
I was wandering if nyone has a script to move files older than x days old? i've seen several to delete, but I don't want to delete. I would like to create a backup of the files first verify with...
2
by: Jim in Arizona | last post by:
I made up a service that will move files from a folder on the machine that the service is running to a share on another machine. I use a try/catch incase an error is thrown and write that error to...
1
by: ajames270 | last post by:
I would like to cretae a program to move files from one directory to another... ex: from c:\in to c:\out so anything in c:\in would be moved. I would like this to run every 30 or 40 seconds.
2
by: AnitaB | last post by:
I have to create a perl script, which is calling a .sql script. This .sql script is creating alphabetic listing of .inc files from A-Z. All the .inc files will be having a suffix with lowercase of...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.