Help::Move Latest(Todays) .dat File between folders on SFTP.

Advertisement

Vk
Guest

Help::Move Latest(Todays) .dat File between folders on SFTP.

Hi EveryOne,
I am a SSIS Developer. I am creating a package which connects to a SFTP Server, for that I am using WINSCP with Stored Session, and accomplishes the below 2 Tasks.

1. get the latest.dat file (i.e. Todays date) from Home/XXX/latest.dat (SFTP Server) to my local directory D:\XXX\latest.dat and
2. I have to rename the file from latest.dat to latest.log and move the file to a Home/XXX/log/ folder on the remote server (i.e SFTP Server).

can somebody please help me with this.

Reply with quote

Advertisement

Vk
Guest

Re: Help::Move Latest(Todays) .dat File between folders on SFTP.

Hi prikryl
Thanks for your reply. Actually I am able to create a batch file with date and time stamp using a script task in my SSIS Package. And In that batch File my commands are::

CD PPP
get ABC_20100331.dat
mv ABC_20100331.dat ABC_20100330.ack /XXX/Ack/
(Rename file by changing extension and move to ACK folder)

mv ABC_20100331.dat /XXX/Processed/

mv ABC_20100331.dat ABC_20100330.log /XXX/Log/
(Rename file by changing extension and move to LOG folder)


I tried till get command, Its working fine. I am able to bring the file which I wanted. The only thing is the next 3 steps. I jus wanna make sure that the 3 move commands as said above will work fine while moving the files between folders after renaming them. I cant check them because the SFTP server is the Production server. Please confirm me that these 3 move comands are correct or not? If not please suggest me some Ideas on this.

Thanks In Advance

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Help::Move Latest(Todays) .dat File between folders on SFTP.

Vk wrote:

mv ABC_20100331.dat ABC_20100330.ack /XXX/Ack/
Possibly you wanted to do:
mv ABC_20100331.dat /XXX/Ack/ABC_20100330.ack

Also you cannot move the same file again, as it is not there anymore.

Reply with quote

Vk
Guest

Re: Help::Move Latest(Todays) .dat File between folders on SFTP.

Hi prikryl

Thanks for your valuable suggestion. I was waiting for your reply. that really helped me. One final question prikryl. Since you told that I cannot use the same file agian in my further steps, Can I use a Copy command to do my required Task?
I mean can I use these following steps shown below::

cp ABC_20100331.dat ABC_20100330.ack
mv ABC_20100330.ack /XXX/Ack/ABC_20100330.ack


cp ABC_20100331.dat ABC_20100330.log
mv ABC_20100330.log /XXX/log/ABC_20100330.log

mv ABC_20100331.dat /XXX/Processed/ABC_20100330.dat

If not can you please suggest me another alternative approach for my task.

Thanks in Advance.

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: Help::Move Latest(Todays) .dat File between folders on SFTP.

You cannot duplicate remote file from script. All you can do is to download it and upload back to a different path.

Reply with quote

Advertisement

You can post new topics in this forum