First steps in scripting

Advertisement

Yves
Guest

First steps in scripting

Hi,

i have tried my first steps in scripting but i was not successfull.

I used the sample script and changed it a little bit like this:

script.scp

# Automatically answer all prompts negatively not to stall
# the script on errors
option batch on
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect using a password
# open user:password@example.com
# Connect
open myuser:mypassword@myhost
# Change remote directory
cd /folder
# Force binary mode transfer
option transfer binary
# Download file to the local directory c:\
get config.h c:\
# Disconnect
close
# Exit WinSCP
exit

To execute it i used to following command:

c:\programme\winscp3\WinSCP3.com /console /script=script.scp

After this a window has opened and closed fast.

A manual connect by winscp is possible.

Whats my mistake? :?

Thanks for help!

Reply with quote

Advertisement

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

Re: First steps in scripting

Run the script from already opened console window (type 'cmd' into start/run box) to keep the results once the script finishes.

Reply with quote

Yves
Guest

Hi,

thanks for your replay.

I get the error message

Cannot open file script.scp

The script is in the WinSCP folder.

Reply with quote

Yves
Guest

ok, my fault.

Now I get the following:
C:\Programme\WinSCP3>
batch        on
confirm      off
EAccessViolation
Keine Sitzung
transfer     binary
Keine Sitzung
Keine Sitzung

Reply with quote

Advertisement

Christoph
Guest

having similar problem

Hello all

Using Win2000 I'm facing the same issue: Using plain command "winscp3.exe /console /script=connect.txt" from command line is showing same result as Yves is reporting (while script-file is an adapted copy from the documentation-site). I went done to 3.7.6 as recommended but no change.
What I found interesting is the fact that the script command is not listed when typing help on the console (started with winscp3.exe /console). Does this ev. have any meaning or did I somehow miss an important part in the documentation? Thanks for your efforts

/Christoph, Berne-CH

Reply with quote

Christoph
Guest

PostRe: having similar problem

Hi Martin

Well, one has to differntiate:

- "winscp3.exe /console /script=c:\programme\winscp3\connect.txt" is resulting in that very short popping window Yves already mentioned while

- "winscp3.com /console /script=c:\programme\winscp3\connect.txt" results in the error message "cannot open file c:\programme\winscp3\connect.txt"

Moreover: "winscp3.com xxx@host.tdl /console (xxx@host.tdl is the default session in the GUI) is properly opening the session ending with the command line on the console; the same with .exe instead of .com just with the difference an addition window is opened.

So, what about that error-message; do you have an idea?

Reply with quote

martin
Site Admin
martin avatar

Re: PostRe: having similar problem

Christoph wrote:

So, what about that error-message; do you have an idea?
I guess that it is pointless to ask you whether the file really exists and whether you have read access to the file :-)

Reply with quote

Advertisement

Christoph
Guest

Martin,

I really have to appologize! The file does exist but it's named connect.txt.txt (some remaining typing from the old days with DOS; that's what's happening if project managers try to work outside their core competences ...).
Long story short: It's working fine now

Again sorry about that and thanks for following up on this anyway!
/Christoph

Reply with quote

Advertisement

You can post new topics in this forum