ramsey_lewis
ramsey_lewis

Reputation: 598

Use PuTTY to upload files inside a batch file

In my batch file I have the following code:

cd /D "C:\Putty.0.63"
psftp -b D:\batch\psftp.txt [email protected] -pw myPassword

pause

psftp.exe is in the C:\Putty.0.63 location.

In psftp.txt I have open ftp.server.com

I can log in to the ftp server but I don't know how to put a file. I tried to put cmd in the batch file or the textfile, but nothing works. Looks like I can't do put inside a batch file.

Any ideas?


Solved:

In psftp.txt I had : open ftp.server.com put myFile.sql to make it work I removed the first line and just left the put myFile.sql in the file. I didn't need the open ftp.server.com because i was already opening the connection in the batch file with [email protected] -pw myPassword

Upvotes: 1

Views: 1139

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202292

You are opening a connection twice:

  1. On psftp command-line using [email protected] -pw myPassword
  2. In script file using open ftp.server.com.

The open command fails, as you are already connected. So the put command never executes.

Upvotes: 1

Related Questions