How do you output batch DOS FTP to a textfile?

Posted on 2006-05-14
Last Modified: 2008-01-09

I have the following perl script for some testing. Right now what happens is that the program transfers a number of files in a live DOS screen then closes. What i want to be able to do is output the live dos screen to a text file. Everything in the DOS window is fine it doesn't need to be just the filtered results.

Many thanks in advance.


# ftp script for TCP-PEP test bench

$num_args = $#ARGV + 1;

if ($num_args != 5)
   print "Script Usage ...\n";
   print "perl <server ip addr> <userid> <password> <mode> <ftp file name>\n";
   print "<server ip addr> : IP address which ftp will connect to\n";
   print "<userid>         : win-xp, win-2k, win-2003 or MAC \n";
   print "<password        : password \n";
   print "<mode>           : get for ftp-get and put for ftp-put\n";
   print "<ftp file name>  : file name used for ftp\n";
   die "Try again ...\n";

$server = $ARGV[0];
$userid = $ARGV[1];
$password = $ARGV[2];
$mode = $ARGV[3];
$filename = $ARGV[4];

open (cmdfile, ">test.cmd") || die ("Could not open file. $!");

print cmdfile "open $server\n";
print cmdfile "$userid\n";
print cmdfile "$password\n";
print cmdfile "hash\n";
print cmdfile "bin\n";

if ($ARGV[3] eq "put")
    print cmdfile "cd put\n";
    print cmdfile "put $filename $filename.put\n";
    print cmdfile "cd get\n";
    print cmdfile "get $filename $filename.get\n";

print cmdfile "bye\n";

close (cmdfile) || die ("Could not write file. $!");

system 'ftp -s:test.cmd';

Question by:xaero_cool
    LVL 8

    Assisted Solution

    do not have DOS so can not test this mut I would expect:

    system 'ftp -s:test.cmd >capturedOutput';

    to do what you want
    LVL 4

    Accepted Solution

    creates output.log (or deletes existing) and put the output in there
    system 'ftp -s:test.cmd > output.log';

    or if you want to append to the log:
    system 'ftp -s:test.cmd >> output.log';

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
    A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (,  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now