Link to home
Avatar of AmyLG67
AmyLG67

asked on

FTP Error - Error Opening Local File

I have an FTP script that contains the following commands:

open ftp.ftpsite.com
username
password
cd NVDv2_US_EN
cd All
ascii
lcd C:\Temp
get jpg_v2_2009.zip
bye

I run this script using the command

ftp -s:C:\Temp\FTPConnectionInfo.txt

When I run it, it fails with the following error:

Error opening local file jpg_v2_2009.zip
Invalid argument

When I run the same commands interactively, I do not get the error.  Any ideas as to what the problem might be?  Thank you!
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

Remove the line ASCII or change it to BINARY.  A zip file is a binary file.
Is that zip file on the remote server and you want to download it or where is that file?
bol
Avatar of AmyLG67
AmyLG67

ASKER

Thanks, bol.

I changed the ASCII line to BINARY.  However, I still get the same error.

The zip file is on the remote server and I want to bring it down to the local machine.

Thank you!
Amy
I overlooked one other problem.  The lcd line should not have the drive letter and colon.  Those aren't valid for changing a directory.  To test that I am right you could remove that line completely and see if this works.  Run it from the C:\Temp folder if you can to test that I am right or just look for the downloaded folder in the directory where the script is run.
If you do need to change the directory then use ...
cd \Temp
That does assume that you are already on the C drive.  If that needs to be changed then let me know.  Let me know if you have a question or how this works.
bol
 
Avatar of AmyLG67

ASKER

Hi bol,

I took out the lcd line completely, but still get the same error.  :(

The really odd thing is, if I run the exact same commands interactively, there is no error and the file is downloaded successfully.  Why would it be different if it's run from a script?

Thanks for your help!
Amy
What OS are you using?  Honestly I usually use a 3rd party program for my FTP called WSFTP Pro.  It also supports scripts, like this, and I find it much better than the ftp included with the OS.  Just a thought/recommendation. :)
What happens if you try another file?  I was actually wrong about the lcd command so please disregard that.
I am puzzled by the error though.  Is it possible you have a blank line or something else in the text file?  I tried a similar test using ftp built in to Windows (2000) and using a text file like you did worked fine.  Do you have luck with other scripts like this or is this the only one you have tried?
Let me know how this helps or if you have a question.
bol
Avatar of AmyLG67

ASKER

Hi bol,

I can only get zip files from this particular ftp site, but all of them fail.

I'm using XP Pro SP2.  I also tried the same script on a server running Win2003 Standard SP2.  There, I got two messages:

200 Port command successful
No such file or directory

Again, if I run it interactively on the Win2003 server, no problem, no error, I get the file.

Thanks for the tip, I only have WSFTP LE, and I think it's pretty old (it was given to me by my employer).  In any case, that's not on the server so I ultimately have to find something that works on the server.

I've done tons of FTP scripts before in the same way and I've never run into this error before.  Could there be something on the server that I'm logging onto that could be causing this?

Thanks!
Amy
There could be some cause on the server.  Is this script actually running on the server or connecting to it?
What was the line that caused the "no such file or directory" error?  You might check case to make sure that isn't the problem.  Some servers will be sensitive to it.  What do you see if you use the ls command (i.e. the letters L and S for a directory list)?
The different errors are puzzling to me since they should be coming from the server, which I would think is the same.  Of course the FTP "program" will affect the error reporting a bit.  Is there a way to see the complete log or output of that script (of course omit or edit sensitive info)?
bol
Avatar of AmyLG67

ASKER

The script is connecting to a remote server.

The line that caused "no such file or directory" was "get jpg_v2_2009.zip".  That would seem like a very straightforward error, but there *is* such a directory and file, and I can get it when I do the commands interactively.

If I do a "ls" command I get a list of all the files in the directory.

Here's what I get in a file called ftplog.txt when I run the script file using "ftp -s:C:\Temp\FTPConnectionInfo.txt > c:\temp\ftplog.txt

ftp> Connected to ftp.sitename.com.

open ftp.sitename.com
220 999.999.999.99 FTP server ready
User (ftp.sitename.com:(none)):
331 Password required for username.

230 User username logged in.
ftp> cd NVDv2_US_EN
250 CWD command successful
ftp> cd All
250 CWD command successful
ftp> binary
200 Type set to I
ftp> Local directory now C:\Temp.

ftp> lcd C:\Temp
Interactive mode Off .

ftp> prompt
ftp> get jpg_v2_2009.zip

ftp> get nvd_v2_2005.zip

ftp> get nvd_v2_2006.zip

ftp> get nvd_v2_2007.zip

ftp> get nvd_v2_2009.zip

bye
221 Goodbye.

While this is running, the cmd window shows the following (this is literal):
.rror opening local file jpg_v2_2009.zip
:Invalid argument
.rror opening local file nvd_v2_2005.zip
:Invalid argument
.rror opening local file nvd_v2_2006.zip
:Invalid argument
.rror opening local file nvd_v2_2007.zip
:Invalid argument
.rror opening local file nvd_v2_2008.zip
:Invalid argument

There really is that dot before rror and the : before the second message.

Thanks for all your help, I appreciate it!
Amy
SOLUTION
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
ASKER CERTIFIED SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.