Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Redirecting STDIN into FTP

338 views
Skip to first unread message

Syltrem

unread,
Mar 24, 2010, 4:05:20 PM3/24/10
to
Hi

It looks like I can somewhat redirect STDIN into FTP, like :

C:> copy con: F.TXT
open myserver
username
password
quit
^Z
Filed copied

C:> type f.txt | ftp
User (MYSERVER:(none)): Password:

See, FTP happily executes the 1st command from the F.TXT (open myserver) but
then it does not read the next lines in the file and asks for user input on
the screen. Moreover, it skips asking for the username and goes directly to
asking the password.

I know I can use the switch -S:F.TXT with FTP, but I cannot use this as I
would like to avoid having a temporary file like F.TXT above.
What I really would like to do is :

C:> echo open myserver^

username^

PassWord^

quit | FTP

The ECHO command displays the text on multiple lines, exactly how it is in
the F.TXT in my 1st example, and pipe it into FTP like I did above. But
again, it only reads the 1st line of input then goes back to using the
screen. Only the 1st line of the file is used.

My goal is to avoid storing usernames and passwords in a temporary file that
may eventually be seen by someone. I know I can delete the file immediately
after running the FTP, but if the FTP runs for 15 minutes, or something
happens and the file is not deleted ?

If anyone has an idea on how to do this I'd gladly hear it.
If only the PIPE device would have a name, I could do something
like -S:PipeDevice but I don't believe it is a named device that can be used
this way in DOS.

Thanks
Syltrem
http://pages.infinit.net/syltrem


Tom Lavedas

unread,
Mar 24, 2010, 5:28:42 PM3/24/10
to

Try something like this ...

@echo off
setlocal
set UID=%1
if [%1]==[] set /p UID="Enter your user ID:"
if [%1]==[] %0 %UID%
(
echo open yourserver
echo %1
echo LS
echo quit
) | ftp.exe

As far as I can tell, the password MUST be entered at run time. The
ftp client does not accept a piped input for that.
_____________________
Tom Lavedas

Ted Davis

unread,
Mar 24, 2010, 8:29:51 PM3/24/10
to
On Wed, 24 Mar 2010 16:05:20 -0400, Syltrem wrote:

> If anyone has an idea on how to do this I'd gladly hear it. If only the
> PIPE device would have a name, I could do something like -S:PipeDevice
> but I don't believe it is a named device that can be used this way in
> DOS.

One word: netcat

Google it. Google netcat ftp and get a link to a manual.

netcat is the Swiss Army knife of Network administrators, and it's free.

Named pipes *do* exist in Windows, but CMD can't access them. http://
en.wikipedia.org/wiki/Named_pipe#Named_pipes_in_Windows

--
Ted Davis (tda...@mst.edu)

0 new messages