We help IT Professionals succeed at work.

Batch FTP Scrip

devondan
devondan used Ask the Experts™
on
I am trying to put together a really simple batch file that I can use to upload a file from a Windows machine via FTP. I'm sure I am doing something that is quite obviously wrong to someone who writes stuff like this every day, but I can't work out.

My script looks like this:

However, I get a "500 unable to service PORT commands" error.

The hosting company (Awardspace) have an extensive set of FAQ that states that all FTP clients must be set to Passive for transfers. Yet, if I do this line by line in cmd, it clearly states "Entering passive mode"....

Can anyone see an obvious mistake?

Thanks in advance for your time and assistance,

Dan
@ftp -i -s:"%~f0"&GOTO:EOF 
ftp danpearce.co.uk 
username
password 
!:--- FTP commands below here --- 
quote PASV 
cd remote_directoty
lcd desktop 
mput "filename.ext" 
disconnect 
bye

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007

Commented:
Kamaraj SubramanianApplication Support Analyst

Commented:
I would double check the firewall settings in the Windows XP to be sure

Author

Commented:
Hi Omarfarid,

Thanks for your help. I've seen several of these styles of solutions. While the one you linked to makes complete sense, in this instance, I get the same error

500 unable to service port commands

Even when I add the line "quote PASV" to the myftp.txt file (which is the normal source of a 500 error with this host). Here is what the output looks like....

C:\>ftp -s:C:\myftp.txt danpearce.co.uk
Connected to danpearce.co.uk.
220 82.197.131.90 FTP server ready
User (danpearce.co.uk:(none)):
331 Password required for username.

230 Welcome to your web hosting account!Please upload your web site inside the directory of the respective hostname.(If you wish to upload outside the hostname directories or delete them please make sure Directory Protection is set to OFF from your hosting control panel - File Manager section)
ftp> lcd desktop
desktop: F
ftp> quote PASV
227 Entering Passive Mode (82,197,131,90,192,13).
ftp> put "filename.ext"
500 Unable to service PORT commands
421 Idle Timeout (60 seconds): closing control connection.
Connection closed by remote host.
ftp> quit

Please note, directory protection is set to off

Any other ideas?
Kamaraj SubramanianApplication Support Analyst

Commented:
This is happening because of the firewall settings

please switch off the firewall and try it

If you have any antivirus software check there also, whether it blocks the outgoing or not
Top Expert 2007
Commented:
Can you login and run commands manually? if not then you need to contact your provider to see if they have a problem on their side

Author

Commented:
Hi itkamaraj,

Thanks for your suggestion. I will have to do some more reading into this. Although as far as I know, there is nothing that should be stopping it running (on Vista) and the batch file is run as administrator.

Omarfarid: No I can't. Not in the way I would normally anyway. So I will fire off a request to them and see what comes back.

Thank you both for your help.

Dan

Author

Commented:
Turns out this is a problem with the hosting company, Awardspce. Their response:

"We have tested the commands on a Windows machine and they simply do not work. There is no problem for shell commands from a Unix machine however using the same commands and idea to upload files via script/batch file.

There are also lots of comments on the Internet that the passive mode is not actually supported quite good on the FTP client integrated in Windows OS."

Will have to think of something else then. Thanks for all your advice all the same.

Dan