FTP a file:Get return code if ftp is unsucessful.
Moderator: DosItHelp
FTP a file:Get return code if ftp is unsucessful.
Hi All,
I am trying to ftp a file using standard ftp command as - ftp -s:test.ftp. The "test.ftp" consist of below commands:
open 11.11.11.11
user
password
put file1
quit
The file is ftp'd successfully but the logs does not show me any return code as 0 or success message. I want some return code to be displayed so that if ftp is not successful due to any reason like - Connection failed, login incorrect or Traget not available then i can display message as "FTP was not successful". Can someone please help?
I am trying to ftp a file using standard ftp command as - ftp -s:test.ftp. The "test.ftp" consist of below commands:
open 11.11.11.11
user
password
put file1
quit
The file is ftp'd successfully but the logs does not show me any return code as 0 or success message. I want some return code to be displayed so that if ftp is not successful due to any reason like - Connection failed, login incorrect or Traget not available then i can display message as "FTP was not successful". Can someone please help?
Re: FTP a file:Get return code if ftp is unsucessful.
You can redirect all the output from the FTP session to a file and then parse the log file for success or failures.
Re: FTP a file:Get return code if ftp is unsucessful.
yes I did that but I need some kind of return codes to check if ftp was successful.The current logs does not give any successful message when file gets ftp'd so it becomes very difficult to check status.Squashman wrote:You can redirect all the output from the FTP session to a file and then parse the log file for success or failures.
Re: FTP a file:Get return code if ftp is unsucessful.
I disagree. I use windows built-in ftp client about 300 times a day for my automation and it always returns a successul transfer in the output log when it transfers successcully.
Re: FTP a file:Get return code if ftp is unsucessful.
Squashman wrote:I disagree. I use windows built-in ftp client about 300 times a day for my automation and it always returns a successul transfer in the output log when it transfers successcully.
Can u please let me know which command you are using to ftp the file? Is it ftp -d -s:temp.text? temp.text consist of all credentials.
Re: FTP a file:Get return code if ftp is unsucessful.
All my FTP commands are launched from batch files like this.
Code: Select all
ftp -n -i -s:"E:\PathtoBatchFiles\ClientNameFTPscript.scr" >"E:\PathtoLogFiles\ClientNameFTPscript.txt"
Re: FTP a file:Get return code if ftp is unsucessful.
Squashman wrote:All my FTP commands are launched from batch files like this.Code: Select all
ftp -n -i -s:"E:\PathtoBatchFiles\ClientNameFTPscript.scr" >"E:\PathtoLogFiles\ClientNameFTPscript.txt"
I tried using this command but it says invalid parameter. i guess its not recognizing ftp -n -i option. Instead i used ftp -d but still it didnt give me "Transfer completed" message. Any pointers?
Re: FTP a file:Get return code if ftp is unsucessful.
sam14189 wrote:I tried using this command but it says invalid parameter. i guess its not recognizing ftp -n -i option. Instead i used ftp -d but still it didnt give me "Transfer completed" message. Any pointers?
If it is not recognizing the options then I would suspect there is another ftp client installed on your computer and it is not using Microsoft's built-in FTP client.
http://ss64.com/nt/ftp.html
Re: FTP a file:Get return code if ftp is unsucessful.
Squashman wrote:sam14189 wrote:I tried using this command but it says invalid parameter. i guess its not recognizing ftp -n -i option. Instead i used ftp -d but still it didnt give me "Transfer completed" message. Any pointers?
If it is not recognizing the options then I would suspect there is another ftp client installed on your computer and it is not using Microsoft's built-in FTP client.
http://ss64.com/nt/ftp.html
If that is the case then how can i check which ftp client is installed on my computer?
Re: FTP a file:Get return code if ftp is unsucessful.
Open a cmd window and type ftp /? to see what it prints.
Which OS are you using?
This is what I see in Windows 8.1
Which OS are you using?
This is what I see in Windows 8.1
Code: Select all
d:\>ftp /?
Transfers files to and from a computer running an FTP server service
(sometimes called a daemon). Ftp can be used interactively.
FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-A] [-x:sendbuffer] [-r:recvbuffer] [-b:asyncbuffers] [-w:windowsize] [host]
-v Suppresses display of remote server responses.
-n Suppresses auto-login upon initial connection.
-i Turns off interactive prompting during multiple file
transfers.
-d Enables debugging.
-g Disables filename globbing (see GLOB command).
-s:filename Specifies a text file containing FTP commands; the
commands will automatically run after FTP starts.
-a Use any local interface when binding data connection.
-A login as anonymous.
-x:send sockbuf Overrides the default SO_SNDBUF size of 8192.
-r:recv sockbuf Overrides the default SO_RCVBUF size of 8192.
-b:async count Overrides the default async count of 3
-w:windowsize Overrides the default transfer buffer size of 65535.
host Specifies the host name or IP address of the remote
host to connect to.
Notes:
- mget and mput commands take y/n/q for yes/no/quit.
- Use Control-C to abort commands.
Re: FTP a file:Get return code if ftp is unsucessful.
Same output I get for Windows 7.
Re: FTP a file:Get return code if ftp is unsucessful.
Squashman wrote:Same output I get for Windows 7.
Yes i am also using Windows 7 32 bit operating system and this is what i see:
C:\> ftp /?
Transfers files to and from a computer running an FTP server service
(sometimes called a daemon). Ftp can be used interactively.
FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-A] [-x:sendbuffer] [-r:recvbuf
fer] [-b:asyncbuffers] [-w:windowsize] [host]
-v Suppresses display of remote server responses.
-n Suppresses auto-login upon initial connection.
-i Turns off interactive prompting during multiple file
transfers.
-d Enables debugging.
-g Disables filename globbing (see GLOB command).
-s:filename Specifies a text file containing FTP commands; the
commands will automatically run after FTP starts.
-a Use any local interface when binding data connection.
-A login as anonymous.
-x:send sockbuf Overrides the default SO_SNDBUF size of 8192.
-r:recv sockbuf Overrides the default SO_RCVBUF size of 8192.
-b:async count Overrides the default async count of 3
-w:windowsize Overrides the default transfer buffer size of 65535.
host Specifies the host name or IP address of the remote
host to connect to.
Notes:
- mget and mput commands take y/n/q for yes/no/quit.
- Use Control-C to abort commands.
I am not sure why -n is not working
Re: FTP a file:Get return code if ftp is unsucessful.
sam14189 wrote:Squashman wrote:All my FTP commands are launched from batch files like this.Code: Select all
ftp -n -i -s:"E:\PathtoBatchFiles\ClientNameFTPscript.scr" >"E:\PathtoLogFiles\ClientNameFTPscript.txt"
I tried using this command but it says invalid parameter.
sam14189 wrote:I am not sure why -n is not working
Paste in the exact command you used and the reason may become clear.
Re: FTP a file:Get return code if ftp is unsucessful.
Why are you hell bent on using -D?
Re: FTP a file:Get return code if ftp is unsucessful.
Squashman wrote:Why are you hell bent on using -D?
Because i want logs of ftp to check whether file was ftp'd or not. Apart from -d none of the other options are working in my case.