open 10.1.1.1
USER global123
globnew
bin
put myfile.txt myfilenew.txt
quit
FTP a file:Get return code if ftp is unsucessful.
Moderator: DosItHelp
Re: FTP a file:Get return code if ftp is unsucessful.
Try this in your script file. I have seen several FTP servers that don't like it when you don't specify the USER command. As you can see in my examples I always use it. I am not sure if that is why you are seeing INVALID COMMAND errors.
Re: FTP a file:Get return code if ftp is unsucessful.
Squashman wrote:Try this in your script file. I have seen several FTP servers that don't like it when you don't specify the USER command. As you can see in my examples I always use it. I am not sure if that is why you are seeing INVALID COMMAND errors.open 10.1.1.1
USER global123
globnew
bin
put myfile.txt myfilenew.txt
quit
OK.. i will try this also and let you know the results.
Re: FTP a file:Get return code if ftp is unsucessful.
I used your exact filenames and folders and batch file - just changing the script as below
as Squashman suggested by adding user and also separating the put commands:
and this is the log file:
as Squashman suggested by adding user and also separating the put commands:
Code: Select all
open astronomy.com
user captainkirk
enterprise
bin
put myfile.txt
put myfilenew.txt
quit
and this is the log file:
Code: Select all
ftp> open astronomy.com
Connected to astronomy.com.
220---------- Welcome to Pure-FTPd [privsep] ----------
220-You are user number 24 of 500 allowed.
220-Local time is now 18:32. Server port: 21.
220-This is a private system - No anonymous login
220 You will be disconnected after 3 minutes of inactivity.
ftp> user captainkirk
331 User captainkirk OK. Password required
230-OK. Current restricted directory is /
230-225 files used (2%) - authorized: 10000 files
230 155390 Kbytes used (10%) - authorized: 1536000 Kb
ftp> bin
200 TYPE is now 8-bit binary
ftp> put myfile.txt
200 PORT command successful
150 Connecting to port 52718
226-226 files used (2%) - authorized: 10000 files
226-155390 Kbytes used (10%) - authorized: 1536000 Kb
226-File successfully transferred
226 0.560 seconds (measured here), 132.17 bytes per second
ftp: 74 bytes sent in 0.28Seconds 0.26Kbytes/sec.
ftp> put myfilenew.txt
200 PORT command successful
150 Connecting to port 52719
226-227 files used (2%) - authorized: 10000 files
226-155390 Kbytes used (10%) - authorized: 1536000 Kb
226-File successfully transferred
226 0.556 seconds (measured here), 136.80 bytes per second
ftp: 76 bytes sent in 0.28Seconds 0.28Kbytes/sec.
ftp> quit
221-Goodbye. You uploaded 1 and downloaded 0 kbytes.
221 Logout.
Re: FTP a file:Get return code if ftp is unsucessful.
Foxidrive,
He is just uploading one file. The second file name in the put statement is file name you want it to be on the ftp site. Basically renaming the file on the upload.
He is just uploading one file. The second file name in the put statement is file name you want it to be on the ftp site. Basically renaming the file on the upload.
Re: FTP a file:Get return code if ftp is unsucessful.
Squashman wrote:Foxidrive,
He is just uploading one file. The second file name in the put statement is file name you want it to be on the ftp site. Basically renaming the file on the upload.
Thank you - I wasn't aware of that.
Re: FTP a file:Get return code if ftp is unsucessful.
Hi Squashman and foxidrive - I tried using the way you mentioned, it worked but using -n and -i options i am not able to see logs at all. I can only see below in log file:
open 10.1.1.1
user global123
bin
myfile.txt myfilenew.txt
quit
So even if file was ftp'd but no logs are generated at all.
open 10.1.1.1
user global123
bin
myfile.txt myfilenew.txt
quit
So even if file was ftp'd but no logs are generated at all.
Re: FTP a file:Get return code if ftp is unsucessful.
I have no idea what could be wrong with your system. I literally generate hundreds of FTP logs every day with the automation I do. I have never seen the log file not come out correctly
Re: FTP a file:Get return code if ftp is unsucessful.
Squashman wrote:I have no idea what could be wrong with your system. I literally generate hundreds of FTP logs every day with the automation I do. I have never seen the log file not come out correctly
Thanks Squashman for being patient and suggesting so many solutions! I will have to look for some other approach to find whether files were ftp'd or not
Re: FTP a file:Get return code if ftp is unsucessful.
sam14189 wrote:Thanks Squashman for being patient and suggesting so many solutions! I will have to look for some other approach to find whether files were ftp'd or not
What you should really do is show how you are doing this - because the problem is 99% guaranteed to be an error on your part in the way your script is running.
We can only help people fix their code when we can see the code and know how it is being launched - it makes sense, right?
Type over your password and username and servername - or use captainkirk - and give all the details.
The text you've shown above is basically the FTP script itself.
See here: viewtopic.php?f=3&t=6108
Re: FTP a file:Get return code if ftp is unsucessful.
Yes. I have seen some weird goofy output get redirected to FTP log files when the FTP command is being used with a script and being called from a 3rd party program. One of my automation applications has a tendency to output the script file to the log file yet executes without any problems. I figured out a work around for it, but the software vendor has no clue why it is happening.
Re: FTP a file:Get return code if ftp is unsucessful.
OK. I will tell you the exact process.However i can not mention server name, user id and password due to copyright issues. I hope you understand that. This is what i am trying to do:
There is a tool called IBM WTX, basically a application which does some other processing apart from executing this batch script to ftp the file.This WTX is not running on windows rather this application is deployed on server. For this reason we have kept our batch script program also on server. When the file is ftp'd it is posted to another server via the firewall. So i am assuming the logs are not getting displayed properly due to firewall in between. Here are the contents of file:
Batch File:demo.bat
Code:
ftp -i -n -s:"<server path>\temp.txt" >"<server path>\logs.txt"
Contents of temp.txt
Code:
open 10.1.1.1
global123
globnew
bin
put myfile.txt myfilenew.txt
quit
When demo.bat is executed then logs.txt consist of:
Code:
Invalid command.
Invalid command.
open 10.1.1.1
global123
globnew
bin
Please login with USER and PASS.
put myfile.txt myfilenew.txt
Please login with USER and PASS.
Please login with USER and PASS.
quit
Batch File:demo.bat
Code:
ftp -d -s:"<server path>\temp.txt" >"<server path>\logs.txt"
Keeping the contents of temp.txt same, when demo.bat is executed then logs.txt consist of:
Code:
User (10.1.1.1:(none)): open 10.1.1.1
--->
USER global123
--->
PASS globnew
---> bin
TYPE I
---> put myfile.txt myfilenew.txt
PORT 1,2,3,4,5,6
---> STOR myfilenew.txt
---> quit
QUIT
And i checked on server, myfilenew.txt was transmitted.
There is a tool called IBM WTX, basically a application which does some other processing apart from executing this batch script to ftp the file.This WTX is not running on windows rather this application is deployed on server. For this reason we have kept our batch script program also on server. When the file is ftp'd it is posted to another server via the firewall. So i am assuming the logs are not getting displayed properly due to firewall in between. Here are the contents of file:
Batch File:demo.bat
Code:
ftp -i -n -s:"<server path>\temp.txt" >"<server path>\logs.txt"
Contents of temp.txt
Code:
open 10.1.1.1
global123
globnew
bin
put myfile.txt myfilenew.txt
quit
When demo.bat is executed then logs.txt consist of:
Code:
Invalid command.
Invalid command.
open 10.1.1.1
global123
globnew
bin
Please login with USER and PASS.
put myfile.txt myfilenew.txt
Please login with USER and PASS.
Please login with USER and PASS.
quit
Batch File:demo.bat
Code:
ftp -d -s:"<server path>\temp.txt" >"<server path>\logs.txt"
Keeping the contents of temp.txt same, when demo.bat is executed then logs.txt consist of:
Code:
User (10.1.1.1:(none)): open 10.1.1.1
--->
USER global123
--->
PASS globnew
---> bin
TYPE I
---> put myfile.txt myfilenew.txt
PORT 1,2,3,4,5,6
---> STOR myfilenew.txt
---> quit
QUIT
And i checked on server, myfilenew.txt was transmitted.
Re: FTP a file:Get return code if ftp is unsucessful.
sam14189 wrote:Hi Squashman and foxidrive - I tried using the way you mentioned, it worked but using -n and -i options i am not able to see logs at all. I can only see below in log file:
open 10.1.1.1
user global123
bin
myfile.txt myfilenew.txt
quit
So even if file was ftp'd but no logs are generated at all.
So you are no longer getting the INVALID COMMAND error when your run it with the USER command in the script.
Re: FTP a file:Get return code if ftp is unsucessful.
Squashman wrote:sam14189 wrote:Hi Squashman and foxidrive - I tried using the way you mentioned, it worked but using -n and -i options i am not able to see logs at all. I can only see below in log file:
open 10.1.1.1
user global123
bin
myfile.txt myfilenew.txt
quit
So even if file was ftp'd but no logs are generated at all.
So you are no longer getting the INVALID COMMAND error when your run it with the USER command in the script.
Yes that is correct. When i run with "USER" command then invalid error is gone but logs are not generated.
Re: FTP a file:Get return code if ftp is unsucessful.
Manually login to the FTP server from the cmd prompt.
They type: STATUS
They type: STATUS
Re: FTP a file:Get return code if ftp is unsucessful.
You didn't add user in here.
Squashman mentioned that long ago:
viewtopic.php?p=39668#p39668
sam14189 wrote:Code:
open 10.1.1.1
global123
globnew
bin
put myfile.txt myfilenew.txt
quit
Squashman mentioned that long ago:
viewtopic.php?p=39668#p39668