Writing a script in a batch file to fetch files from SSH

Advertisement

viki lingeria
Joined:
Posts:
2

Writing a script in a batch file to fetch files from SSH

Hi ,

I am trying to write a script in a batch file to fetch the files from SSH server.

Have written the following code. But it does not seem to get the files from the server to my local machine.

Can you please tell me what could be going wrong?

Code:
# Automatically answer all prompts negativelly not to stall
# the script on errors
option batch on
# Disable overwrite confirmations that conflict with previous
option confirm off
# Connect
open gstar:gstar@3.49.4.80
# Change remote directory
cd home/data/fs/gstar/25_07_2005
# Force binary mode transfer
# Download file to local directory d:\
get gstar_currency.xml d:\
# Disconnect
close
# Exit WinSCP
exit

Where : gstar is the username and the password.

Your assistance would be highly appreciated.

Regards

Viki Lingeria

Reply with quote

Advertisement

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

Re: Writing a script in a batch file to fetch files from SSH

viki lingeria wrote:

Have written the following code. But it does not seem to get the files from the server to my local machine.
And what does it do?

Reply with quote

Guest

Re: Writing a script in a batch file to fetch files from SSH

martin wrote:

viki lingeria wrote:

Have written the following code. But it does not seem to get the files from the server to my local machine.
And what does it do?

I run the batch file & it gets executed with out any error. Pasting the output file here

C:\># Automatically answer all prompts negativelly not to stall

C:\># the script on errors

C:\>option batch on

C:\># Disable overwrite confirmations that conflict with previous

C:\>option confirm off

C:\># Connect

C:\>open gstar:gstar@3.49.4.80

C:\># Change remote directory

C:\>cd home/data/fs/gstar/25_07_2005

C:\># Force binary mode transfer

C:\># Download file to local directory d:\

C:\>get gstar_currency.xml d:\

C:\># Disconnect

C:\>close

C:\># Exit WinSCP

C:\>exit

Frankly I am not sure where is the script going wrong. Is something missing in the script.

Regards

Viki Lingeria

Reply with quote

martin
Site Admin
martin avatar

Re: Writing a script in a batch file to fetch files from SSH

I have no idea what you are doing. You need to execute the script via WinSCP, not directly (or whatever you are doing)!

Reply with quote

viki lingeria
Joined:
Posts:
2

Re: Writing a script in a batch file to fetch files from SSH

martin wrote:

I have no idea what you are doing. You need to execute the script via WinSCP, not directly (or whatever you are doing)!

Hi Martin,

I am writing the script in a batch file. i.e. in a .bat file extenstion.

Do I have to write the script some where in WinSCP?

Kinldy reply. I am aware my question might have sound stupid. But I am new to WinSCP and I desperately need to transfer files from one server to another.

Please assist.

Regards

Viki Lingeria.

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: Writing a script in a batch file to fetch files from SSH

viki lingeria wrote:

Do I have to write the script some where in WinSCP?
You need to pass it to WinSCP using /script parameter. Please read documentation .

Reply with quote

Advertisement

You can post new topics in this forum