steveniclas
steveniclas

Reputation: 124

Batch Script responds with "Error opening script file" when opening FTP file

I want to use a Batch file to upload files from a folder on my computer.

When I call the FTP Script to do the upload:

FTP -v -i -s:ftp.txt

or

FTP -v -i -s:c:\path\to\file\ftp.txt

Neither of those works, and instead

Error opening script file: ftp.txt

is returned.

Strange thing is, that the exact same script is being executed without problems on another computer.

Opening the batch file with admin-rights does not help. I'm running Windows 10.

Edit: The ftp.txt looks like this:

open ##host##
##user##
##password##

lcd c:\local\path\
cd  path/on/server/
binary
mput "*.xxx"
disconnect
bye

Upvotes: 0

Views: 3875

Answers (3)

Paul Covington
Paul Covington

Reputation: 1

I had to put the .txt file path in the "Start In" section for it to work in Windows Task Manager. No problems since.

Upvotes: 0

anonymous
anonymous

Reputation: 1

I would like to add to this conversation since there have been a lot of views and no solution. I had the same response and it wasn't a permissions issue. It was also no the text file that was the issue because it never technically reached the text file. It was the path to the text file. The following for me didn't work. I had to put quotations around the path even though there were no spaces to confuse the command line.

  • What you tried:

    FTP -v -i -s:c:\path\to\file\ftp.txt

  • What I tried and worked. (I didn't need to use -v, mine works without it)

    FTP -i -s:"c:\path\to\file\ftp.txt"

Running the file acted normal for me. My issue was trying to run the batch file through Windows Task Manager. Somehow, this was causing it to lose the text file somehow. I hope this helps anyone else who reads this thread.

Upvotes: 0

LinuxDisciple
LinuxDisciple

Reputation: 2379

Make a new, empty file with echo >ftp.test and try with that file.

If that gives you the same error, you'll need to look at your execution environment (look at set and the process owner of cmd.exe). It's also possible that the ftp command is being run as a user that doesn't have access to that file.

If you don't get an error then it's probably either a file-permissions or special-character issue with ftp.txt. Retyping the same content into a different file will get around those issues. Remember not to copy/paste because you could accidentally copy invisible special characters that you're trying to avoid.

Upvotes: 1

Related Questions