FTP Scripting

FTP Scripting

Post by freedav.. » Sat, 03 Feb 2001 19:48:20



Can anyone please help. I am having difficulty in creating a script to
run a series of mput statements on a remote server via FTP.

Is it possible to script FTP in Digital UNIX 4.0D or E and if so, how
do I do it?

If anyone can help I would be very grateful.

Cheers
Dave

Sent via Deja.com
http://www.deja.com/

 
 
 

FTP Scripting

Post by Hans Schwengel » Sat, 03 Feb 2001 23:04:03




> Can anyone please help. I am having difficulty in creating a script to
> run a series of mput statements on a remote server via FTP.

> Is it possible to script FTP in Digital UNIX 4.0D or E and if so, how
> do I do it?

> If anyone can help I would be very grateful.

> Cheers
> Dave

> Sent via Deja.com
> http://www.deja.com/

Dear Dave,

        well, in those old times I used the following:
#!/usr/bin/sh
ftp -n ftphost.somewhere.com <<EXIT

cd pub
cd software
binary
get test.tar.gz
quit
EXIT

Hope this helps.

Yours, Hans.

--
===============================================================================
Hans Schwengeler                


Venusstrasse 7
CH-4102 Binningen               PHONE:    +41 61 20 55 422
Switzerland                     FAX:      +41 61 20 55 455
===============================================================================

 
 
 

FTP Scripting

Post by RL Griswol » Sun, 04 Feb 2001 08:08:43



> Can anyone please help. I am having difficulty in creating a script to
> run a series of mput statements on a remote server via FTP.

> Is it possible to script FTP in Digital UNIX 4.0D or E and if so, how
> do I do it?

> If anyone can help I would be very grateful.

> Cheers
> Dave

> Sent via Deja.com
> http://www.deja.com/

I usually use Perl's Net::FTP module.  Here's a simple script that puts
up a single file:

--
#!/usr/bin/perl
use strict;
use Net::FTP;
my ( $execname, $usage, $ftp, $host, $user, $type, $local, $remote );
$execname   = $0;
$execname   =~ s/^.+\///;
$usage      = "Usage: $execname host user local remote
  host       System to FTP file to
  user       User ID for FTP
  type       'A'SCII or 'B'inary
  local      Local file name
  remote     Remote file name (optional, defaults to local name)
";

if ( $#ARGV == 3 ) {


Quote:} elsif ( $#ARGV == 4 ) {



Quote:} else { die $usage; }

if ( ( $type ne 'A' ) and ( $type ne 'B' ) ) { die $usage; }
if ( not ( $ftp = Net::FTP->new( $host ) ) ) {
  die "FTP to $host failed\n";
Quote:}

if ( not $ftp->login( $user ) ) {
  die "FTP to $host as $user failed\n";
Quote:}

if ( $type eq 'A' ) { $ftp->ascii(); } else { $ftp->binary(); }
if ( $remote ) { $remote = $ftp->put( $local, $remote ); }
else           { $remote = $ftp->put( $local );          }
if ( not $remote ) { die "Put of $local failed\n"; }
print "Put $local on $host as $remote\n";
$ftp->quit();
--


#include <stddisclaimer.h>

"But I don't want to go among mad people," Alice remarked.
"Oh, you ca'n't help that," said the Cat:
  "We're all mad here. I'm mad. You're mad."
"How do you know I'm mad?" said Alice.
"You must be," said the Cat, "or you wouldn't have come here."

 
 
 

FTP Scripting

Post by Aneesh Kumar K. » Tue, 06 Feb 2001 19:17:12


You can use lftp binary . If you don't have i can mail it you . It is a
straight forward compilation .

 -aneesh



> > Can anyone please help. I am having difficulty in creating a script to
> > run a series of mput statements on a remote server via FTP.

> > Is it possible to script FTP in Digital UNIX 4.0D or E and if so, how
> > do I do it?

> > If anyone can help I would be very grateful.

> > Cheers
> > Dave

> > Sent via Deja.com
> > http://www.deja.com/

> I usually use Perl's Net::FTP module.  Here's a simple script that puts
> up a single file:

> --
> #!/usr/bin/perl
> use strict;
> use Net::FTP;
> my ( $execname, $usage, $ftp, $host, $user, $type, $local, $remote );
> $execname   = $0;
> $execname   =~ s/^.+\///;
> $usage      = "Usage: $execname host user local remote
>   host       System to FTP file to
>   user       User ID for FTP
>   type       'A'SCII or 'B'inary
>   local      Local file name
>   remote     Remote file name (optional, defaults to local name)
> ";

> if ( $#ARGV == 3 ) {


> } elsif ( $#ARGV == 4 ) {


> } else { die $usage; }
> if ( ( $type ne 'A' ) and ( $type ne 'B' ) ) { die $usage; }
> if ( not ( $ftp = Net::FTP->new( $host ) ) ) {
>   die "FTP to $host failed\n";
> }
> if ( not $ftp->login( $user ) ) {
>   die "FTP to $host as $user failed\n";
> }
> if ( $type eq 'A' ) { $ftp->ascii(); } else { $ftp->binary(); }
> if ( $remote ) { $remote = $ftp->put( $local, $remote ); }
> else           { $remote = $ftp->put( $local );          }
> if ( not $remote ) { die "Put of $local failed\n"; }
> print "Put $local on $host as $remote\n";
> $ftp->quit();
> --


> #include <stddisclaimer.h>

> "But I don't want to go among mad people," Alice remarked.
> "Oh, you ca'n't help that," said the Cat:
>   "We're all mad here. I'm mad. You're mad."
> "How do you know I'm mad?" said Alice.
> "You must be," said the Cat, "or you wouldn't have come here."

--

"I suspect it won't be long before parents start hearing

'Mom, Dad, please can I have the administrator password
to

my t-shirt?! I promise not to put anything bad on
it!!'"

-Jeff

 
 
 

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. Question about /proc/pid/as

3. FTP Scripts

4. CDROM problems

5. FTP script

6. squid config

7. FTP script question...

8. DPT SCSI Alpha driver problems....

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