Topic "ftp to winscp script conversion problem"

Author Message
Levievre

Guest


Hello,

I would like to subsitute microsoft ftp with winscp but can't achieve to put a file on a server.


Here is myscript.txt file :

open ftp://username:password@ftp.example.com/
cd /archive
put -transfer=ascii myfile.txt
exit

I use a computer under windows XP, launch cmd.exe and then type the following command :
winscp.com /script=myscript.txt /ini=nul /log=mylogfile.txt

Could you tell me what is wrong with my script ?

Thank you,
Levievre from France.
Advertisements
JeroenE
[View user's profile]

Joined: 2014-02-13
Posts: 9
Location: The Netherlands
What happens? Do you get errors? What does it say in your logfile?
Levievre

Guest


I have no errors in the log file.

I did some searches and found a solution in a another topic :

I added an ls command between put and exit and then it works.

But I have another problem. I can't convert this command to winscp correctly :

get -transfer=ascii myfile.txt c:rename.txt

It works but I get myfile.txt in my local directory instead of rename.txt

Thank you for tour help.
jrp78
[View user's profile]

Joined: 2016-10-07
Posts: 16
Location: SoVA
I believe you would want to use the mv command.

https://winscp.net/eng/docs/scriptcommand_mv
Levievre

Guest


Jrp78,

I need to upload a file with a new name in my local directory but I don't want to rename the file in the remote directory.

Do you think I can use the mv command for this purpose ?
Guest




Ahh, I'm not sure on renaming local. However, I will say if you are using windows batch file to call the script in the first place, why not just use the DOS ren command right after the script is done?

winscp.com /script=myscript.txt /ini=nul /log=mylogfile.txt
cd filedirectory
ren myfile.txt newname.txt
Levievre

Guest


I was thinking about this solution. i can create a batch file to delete the newname.txt file if already exists then renaming the uploaded file to newname.txt.

Since I have to execute first Winscp.com then launch the batch file, this is a long path when comparing this solution with my original microsoft ftp command.
jrp78
[View user's profile]

Joined: 2016-10-07
Posts: 16
Location: SoVA
I was thinking you would put both winscp.com and the other commands all in one batch file. That's how I run my winscp.com script with other dos commands after that fact.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
Quote:
I added an ls command between put and exit and then it works.

This does not make sense. How can this help?

Quote:
get -transfer=ascii myfile.txt c:rename.txt

You are missing a slash. Use c:\rename.txt.
Levievre

Guest


Hello Martin,

Quote:
This does not make sense. How can this help?


I don't know how this can help. I just applied your advice described in this topic :

https://winscp.net/forum/viewtopic.php?t=13708

Quote:
You are missing a slash. Use c:\rename.txt.


With a slash, it does not work better

Levievre
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