FTP Script

FTP Script

Post by Eric Schattschneide » Thu, 15 Jun 2000 04:00:00



Hello;

I am trying to write an FTP script.  The script is going to put a file from
a unix box to a oracle box.  When I run the script it asks me for a
password.  How would you hard code a username and password so it does not
prompt for one:

Here is my code:

ftp nhq1--coor03dev <<eof 2>&1
put /stage/agt/AGT_STD_COLL.AAW00010 d:\ora_utl
quit
eof

Oh what is 2>&1 do?  Where could I look for what they mean.

thanks,
Eric

 
 
 

FTP Script

Post by kevint.. » Thu, 15 Jun 2000 04:00:00


ftp -in << EOF
open mainframe
user USERID PASSWORD
put file.txt 'DATA1.DATA2.DATA3.DATA'
close
quit
EOF



Quote:> Hello;

> I am trying to write an FTP script.  The script is going to put a
file from
> a unix box to a oracle box.  When I run the script it asks me for a
> password.  How would you hard code a username and password so it does
not
> prompt for one:

> Here is my code:

> ftp nhq1--coor03dev <<eof 2>&1
> put /stage/agt/AGT_STD_COLL.AAW00010 d:\ora_utl
> quit
> eof

> Oh what is 2>&1 do?  Where could I look for what they mean.

> thanks,
> Eric

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

FTP Script

Post by Chris F.A. Johns » Thu, 15 Jun 2000 04:00:00


: Hello;

: I am trying to write an FTP script.  The script is going to put a file from
: a unix box to a oracle box.  When I run the script it asks me for a
: password.  How would you hard code a username and password so it does not
: prompt for one:

Put some or all of the script in ~/.netrc:

machine ftp.whatever.com
login anonymous

macdef init
binary
[more commands]
<blank line>

chmod a-wrx,u+r ~/.netrc

--
        Chris F.A. Johnson

        -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
               Everything in moderation - including moderation  

 
 
 

FTP Script

Post by Steve Madin » Fri, 23 Jun 2000 04:00:00


: Hello;

: I am trying to write an FTP script.  The script is going to put a file from
: a unix box to a oracle box.  When I run the script it asks me for a
: password.  How would you hard code a username and password so it does not
: prompt for one:

: Here is my code:

: ftp nhq1--coor03dev <<eof 2>&1
: put /stage/agt/AGT_STD_COLL.AAW00010 d:\ora_utl
: quit
: eof

The session you need to emulate is this:

ftp hostname_goes_here
the_ftp_prompt> user username_goes_here  password_goes_here
the_ftp_prompt> put /stage/agt/AGT_STD_COLL.AAW00010 d:\ora_utl
the_ftp_prompt> quit

(The important part is the 'user' command to FTP.)

: Oh what is 2>&1 do?  Where could I look for what they mean.

Short answer: It redirects standard error (stderr) to the
same place as stdout (stdout), so the two may be used as
if they were one intermingled file output stream.

Long answer:
It says "redirect file number 2 into the same place that
file number 1 is going."  These file numbers are how shell
scripts deal with the open/read-write/close paradigm.  There
happen to be three pre-opened files that every program
uses, called 0, 1, and 2.  0 is standard input, 1 is
standard output, and 2 is standard error.  The reason this
'2>&1'  thingy is often used is that most command-line
programs send error messages to the stderr file, and all other
output to the stdout file.  When you look at a program
interactively, you don't really notice because stderr and
stdout are both mapped to the terminal screen.  But when you
want to redirect the output with > or send it through a pipe
with |, then it starts to matter, because those normally only
redirect stdout, not stderr.

To see the difference, try this:

cat non_existing_filename > output_filename

The cat command does not find the file called "non_existing_filename"
and complains, note that the complaint doesn't end up in the
output filename, it ends up on the screen.

Now try this:

cat non_existing_filename > output_filename 2>&1

Now this time the error message ends up being in the contents
of the file: output_filename, instead of on the screen.

--
-- ------------------------------------------------------------------
 Steven L. Mading  at  BioMagResBank   (BMRB). UW-Madison          

 B1108C, Biochem Addition / 433 Babcock Dr / Madison, WI 53706-1544

 
 
 

1. Got "Broken pipe" message during FTP session w/FTP script

   Hi,

     I have a problem with the current FTP script that I am using:
   Here it is:

!/usr/bin/ksh

{
cat <<END
ftp -n -v << EOF
open "host"
user "user" "password" "account"
lcd local/directory
END

sed -e 's/.*/get &/' filelist

cat <<END
quit
EOF
END

  What this script is supposed to do is to continuously "get file#.tar.Z."
from the "filelist" in one FTP command.  There are over 100 FILES
to get and this entire process consumes around 30 minutes.

    The MAJOR PROBLEM with this script is when I added the "-v" (verbose)
 command in the initial FTP command.  The reason I added the "-v" command
 was to get some FEEDBACK from the remote FTP server.  I'd say about
 90 percent of the time I get this ERROR displayed on my screen:

-----------------------------------------------------------------
ftp: accept: Protocol error
426 Data connection: Broken pipe.
421 Service not available, remote server has closed connection
Not connected.
Not connected.
Not connected.
Not connected.
-----------------------------------------------------------------

    After this message, I was KICKED OUT of my FTP site and only about
  25 percent of the files are TRANSFERRED OVER.

    The FUNNY THING is that when I GET RID OF the "-v" command in the  
  initial FTP script, EVERYTHING works fine (the script works 100  
  percent of the time).  All my files are safely
  transferred over BUT I want some sort of INDICATION from the remote
  server on what files are being transferred DISPLAYED on my screen.

  Any Suggestions ???

  Thanks,

  Ming.
--
Ming Fung

2. Linux segmentation fault or halt when switching VC

3. FTP Scripts

4. First Time Boot Errors!

5. FTP script

6. Need Inetd and/or Telnetd Source

7. FTP script question...

8. HELP: keyboard

9. ftp script "disappears"

10. FTP SCRIPT

11. Q: how to setup a FTP script

12. auto ftp script

13. Need Help ftp script error checking