• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1790
  • Last Modified:

FTP Batch File logging

I am creating a batch to load files onto an FTP site.  I want to be able to log the batch file's activity and find out if any of the put commands fail.

Here is my simple .bat file script .
ftp -s:c:\ftpmacro.txt www.myftp.com

What do I need to add to this .bat file to enable a log each time it's run?  Or do I modify the actual ftpmacro.txt file that is being called from the .bat file?
Thanks for your help!
0
colsatech
Asked:
colsatech
  • 3
  • 3
1 Solution
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Just add a  >> ftp.log 2>>&1 to it.

For example:

MySimple.Bat >> ftp.log 2>>&1

(The above appends to the log file every time.  Below will overwrite the log file every time).

MySimple.Bat > ftp.log 2>&1
0
 
colsatechAuthor Commented:
Here is my .bat file now...

ftp -s:c:\ftpmacro.txt www.myftp.com
ftpmacro.Bat > ftp.log 2>&1

It displays after the quit command never closes the .bat file when it's done running.  It creates the log file and I can view the log file  but the log file seems to be on a loop.  It finishes logging and then starts all over again.  The log file gets up to about 40KB in size then goes back to 1KB and starts all over again until I manually close the dos window.
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Ok, I'm confused.

Your batch file looks like this:

---------------------------
ftp -s:c:\ftpmacro.txt www.myftp.com
ftpmacro.Bat > ftp.log 2>&1
---------------------------

Or like this:
---------------------------
ftp -s:c:\ftpmacro.txt www.myftp.com
---------------------------

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
colsatechAuthor Commented:
After your post, I've changed it from:
ftp -s:c:\ftpmacro.txt www.myftp.com
to
ftp -s:c:\ftpmacro.txt www.myftp.com
ftpmacro.Bat > ftp.log 2>&1

If I understod your instruction correctly.
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
No, that's wrong.  

The batch file is not be edited.  You simply run the batch command, appending the > ftp.log 2>&1 to the command line.


OTHERWISE, you could modify the batch file to this:

ftp -s:c:\ftpmacro.txt www.myftp.com > ftp.log 2>&1


A little explanation:

Most DOS commands report output to "Standard Out" and errors to "Standard Error".  These are usually the same.  Standard out can be abbreviated as 1 and can also be omitted and it will be assumed, and Standard error can be abbreviated as 2.

By appending > ftp.log to the command line, we're telling the command to send it's output (what it would normally write to the screen on "standard out") to a file named "ftp.log".  By adding the 2>&1 end of that, we're saying any errors sent to "standard error" should be sent to the same place as the standard output instead of the default (which is the screen).
0
 
colsatechAuthor Commented:
Thank you for your help!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now