Topic "If/else or if file exists commands possible?"

Author Message
Dss

Guest


I am using winscp.com scripting and basically trying to first check if a file already exist. If it does, then I want to cancel the rest of the script. I can "fake" this by adding this to my script:

Code:
call if [ -d %MY_FILE_NAME% ]; then echo "Already using current version"; exit; fi


as that breaks the "session" and causes all other commands to just crap out with
No Session.
No Session.
No Session.
No Session.

but is it possible to have a clean exit from the winscp script itself?

Thanks
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
First, for script that involve any conditional processing, using WinSCP .NET assembly is recommended:
http://winscp.net/eng/docs/library

Anyway, make sure you start your script with "option batch abort"
http://winscp.net/eng/docs/scriptcommand_option
And make your "call" command return code >= 2
_________________
Martin Prikryl
Blue_heights

Guest


Hi guys,

I am executing script from windows using batch file and calling winscp internally, i want to perform conditional operation on linux server.
When I execute any if statement it gives me unknown command if.

Please help me, I just need to check if file exists on particular linux path, if not then move file from one linux path to above linux path.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
There's no if command.

See https://winscp.net/eng/docs/script_checking_file_existence
Guest




Thanks...
But it seems that .Net framework uses above command.
Sorry if I am wrong.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
How does that relate to WinSCP script?
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License