Auto login to WINSCP to download a file

Advertisement

Merit
Guest

Auto login to WINSCP to download a file

Need help on this- By executing/running the bat file, it should connect to winscp and download the file to my local system. It should not ask any user Id and password

I have tried in two ways. But no luck. Please help on this.
=======
Case1
=======
By executing the below "Cmd-Txt.bat" file data is downloading but asking userid and password, even though I have mentioned those details in "original.TXT" file(There is no special characters in the password. It contains only alphabets and numeric values only).

Cmd-Txt.Bat file:
====================
cd /d C:\Program Files (x86)\WinSCP
winscp.exe /console /script=C:\Users\VJAYAKRI\Desktop\original.txt
exit
CMD

original.TXT
================
open mysite.com
USEDID
Password
lcd C:\
cd <<directery name where the file is located in mysite.com>>
get <<FileNameToFetch>>.TXT C:\<<DestinationFileName>>.txt
bye

By executing/running the Cmd-Txt.Bat file, it is prompting for use Id and password. Once i have input those details the file is downloaded the file to my local system.
==========================================================================
========
Case 2
========
By executing the below ftp-pull.bat file, it is connecting to winscp without asking the userid and password but file is not downloading.

ftp-pull.bat
============
cd /d C:\Program Files (x86)\WinSCP
winscp ftp://<<USERiD>>:<<PASSWORD>>@MYSITE.com/<<directery name where the file is located in mysite.com>> /explicitssl
get <<FileNameToFetch>>.TXT C:\<<DestinationFileName>>.txt
exit
CMD

By ecevuting the ftp-pull.bat, I am getting the below message in the command line console.
===============================================================
Connecting to MYSITE.com...
Connected with MYSITE.com,negotiatinf SSL connection...
SSL connection established. Waiting for welcome messae...
Connected
Starting the session...
Reading the session...
Session started.
Active session:[1] <<user Id>>@<<mysite>>.com
Winscp>
===============================================================


It is connecting to Winscp with out asking the user Id and password. But the get command is not exectuning it seems, So file is not downloading.


Need your help very urgently to resolve this to download the file through winscp with out giving the use id password manually.
please post on this or reach me on my mail id smeritv@gmail.com, for more details.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
28,262
Location:
Prague, Czechia

Re: Auto login to WINSCP to download a file

Merit wrote:

open mysite.com
USEDID
Password
lcd C:\
cd <<directery name where the file is located in mysite.com>>
get <<FileNameToFetch>>.TXT C:\<<DestinationFileName>>.txt
bye
You cannot specify username and password on separate lines in the script. You have to insert them to session URL. You should also indicate a protocol.

E.g. open ftp://USEDID:Password@mysite.com.

See
https://winscp.net/eng/docs/scriptcommand_open
https://winscp.net/eng/docs/session_url

cd /d C:\Program Files (x86)\WinSCP
winscp ftp://<<USERiD>>:<<PASSWORD>>@MYSITE.com/<<directery name where the file is located in mysite.com>> /explicitssl
get <<FileNameToFetch>>.TXT C:\<<DestinationFileName>>.txt
exit
CMD
You cannot combine WinSCP and Windows commands in a single file.

In both cases you seem to try to put inputs that you typed onto console into a file. But note that in neither case you are using the file as a source for redirected standard input (what wouldn't work anyway), but as a script files that have a different semantics.

Reply with quote

Merit
Guest

Re: Auto login to WINSCP to download a file

Then, How can I download the file. Much appreciated If you provide complete script.


martin wrote:

Merit wrote:

open mysite.com
USEDID
Password
lcd C:\
cd <<directery name where the file is located in mysite.com>>
get <<FileNameToFetch>>.TXT C:\<<DestinationFileName>>.txt
bye
You cannot specify username and password on separate lines in the script. You have to insert them to session URL. You should also indicate a protocol.

E.g. open ftp://USEDID:Password@mysite.com.

See
https://winscp.net/eng/docs/scriptcommand_open
https://winscp.net/eng/docs/session_url

cd /d C:\Program Files (x86)\WinSCP
winscp ftp://<<USERiD>>:<<PASSWORD>>@MYSITE.com/<<directery name where the file is located in mysite.com>> /explicitssl
get <<FileNameToFetch>>.TXT C:\<<DestinationFileName>>.txt
exit
CMD
You cannot combine WinSCP and Windows commands in a single file.

In both cases you seem to try to put inputs that you typed onto console into a file. But note that in neither case you are using the file as a source for redirected standard input (what wouldn't work anyway), but as a script files that have a different semantics.

Reply with quote

Guest

Re: Auto login to WINSCP to download a file

It's working with the below code.

===========================================================================================
cmd-txt.bat
=============
cd /d C:\Program Files (x86)\WinSCP
winscp.exe /console /script=C:\Users\original.txt
exit
CMD

original.txt
=============
open ftp://<<UserName>>:<<password>>@<<mysite>>.com -explicitssl
get <<YouFileName>>.TXT <<DestinationLocation>>\<<NewFileName>>.txt
bye

===========================================================================================

Thanks

Merit wrote:

Then, How can I download the file. Much appreciated If you provide complete script.


martin wrote:

Merit wrote:

open mysite.com
USEDID
Password
lcd C:\
cd <<directery name where the file is located in mysite.com>>
get <<FileNameToFetch>>.TXT C:\<<DestinationFileName>>.txt
bye
You cannot specify username and password on separate lines in the script. You have to insert them to session URL. You should also indicate a protocol.

E.g. open ftp://USEDID:Password@mysite.com.

See
https://winscp.net/eng/docs/scriptcommand_open
https://winscp.net/eng/docs/session_url

cd /d C:\Program Files (x86)\WinSCP
winscp ftp://<<USERiD>>:<<PASSWORD>>@MYSITE.com/<<directery name where the file is located in mysite.com>> /explicitssl
get <<FileNameToFetch>>.TXT C:\<<DestinationFileName>>.txt
exit
CMD
You cannot combine WinSCP and Windows commands in a single file.

In both cases you seem to try to put inputs that you typed onto console into a file. But note that in neither case you are using the file as a source for redirected standard input (what wouldn't work anyway), but as a script files that have a different semantics.

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
28,262
Location:
Prague, Czechia

Re: Auto login to WINSCP to download a file

Anonymous wrote:

It's working with the below code.

===========================================================================================
cmd-txt.bat
=============
cd /d C:\Program Files (x86)\WinSCP
winscp.exe /console /script=C:\Users\original.txt
exit
CMD
That's correct. I'd just recommend you use winscp.com instead of winscp.exe /console to avoid an additional console window from opening.

winscp.com /script=C:\Users\original.txt

See https://winscp.net/eng/docs/executables

Reply with quote

Advertisement

You can post new topics in this forum