Re: ftp from script

2009-01-04 Thread Ed Ahlsen-Girard

Thanks to all.  The below worked.

Grab the snapshots:

#!/usr/bin/perl

use Net::FTP;

unlink /home/ed/snap/*;

my $host = 'rt.fm';

my $ftp = Net::FTP-new($host, Debug =0)
or die Cannot connect to $host: $0;

$ftp-login(anonymous,'-anonymous@')
or die Cannot login , $ftp-message;

$ftp-cwd(/pub/OpenBSD/snapshots/i386)
   or die Cannot change working directory , $ftp-message;

my @ftp_ls = $ftp-ls()
or die Can't get directory listing , $ftp-message;

for (@ftp_ls) {
my $tgz = $_;
unless ($tgz =~ /tgz/) {
next;
}
$tgz =~ s/\S\s{7}?//;
print $tgz\n;
$ftp-get($tgz)
or die get failed , $ftp-message;
}

$ftp-get(INSTALL.i386)
or die get failed , $ftp-message;

$ftp-get(index.txt)
or die get failed , $ftp-message;

$ftp-get(bsd)
or die get failed , $ftp-message;

$ftp-get(bsd.rd)
or die get failed , $ftp-message;

$ftp-cwd(/pub/OpenBSD/snapshots)
   or die Cannot change working directory , $ftp-message;

$ftp-get(ports.tar.gz)
or die get failed , $ftp-message;

exec '/usr/sbin/srcgrab';

exit;


Update source:

#!/bin/sh

export cvsroot=anon...@rt.fm:/cvs

cd /usr

cvs checkout -P src

date



Re: ftp from script

2009-01-04 Thread Randal L. Schwartz
 Ed == Ed Ahlsen-Girard eagir...@cox.net writes:
Ed #!/bin/sh

Ed export cvsroot=anon...@rt.fm:/cvs

Ed cd /usr

Ed cvs checkout -P src

Ed date

You still haven't learned to check the return value of cd. :)

That should be:

 cd /usr || exit 1


-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion



Re: ftp from script

2009-01-04 Thread Markus Lude
On Sun, Jan 04, 2009 at 07:03:38AM -0600, Ed Ahlsen-Girard wrote:
 Thanks to all.  The below worked.
 
 Grab the snapshots:
[...]

 Update source:
 
 #!/bin/sh
 
 export cvsroot=anon...@rt.fm:/cvs
 
 cd /usr
 
 cvs checkout -P src

Why not use cvs update? Of course you need to chdir to /usr/src then.

Regards,
Markus



Re: ftp from script

2009-01-03 Thread Ed Ahlsen-Girard
Randal L. Schwartz wrote:
 Daniel == Daniel A Ramaley daniel.rama...@drake.edu writes:
 

 Daniel chdir /path-to-dir;

 You didn't check the success of the chdir.  This will ruin your original
 current directory if that fails...

 Daniel unlink *;

 Oops!

 The proper solution is rmtree, a function defined in File::Path:

   use File::Path;
   rmtree('/path-to-dir');

   

You're right.  You're so right, in fact, that I'd already changed the 
code; even I noticed that my original was bad practice.

But my real problem was getting the download to work inside a script, 
and none of the presented ideas so far have helped that.

Ed

[demime 1.01d removed an attachment of type APPLICATION/DEFANGED which had a 
name of eagirard.13018DEFANGED-vcf]



Re: ftp from script

2009-01-03 Thread johan beisser

On Jan 3, 2009, at 7:27 AM, Ed Ahlsen-Girard wrote:


You're right.  You're so right, in fact, that I'd already changed the
code; even I noticed that my original was bad practice.


You're doing this in perl, and not using Net::FTP?


But my real problem was getting the download to work inside a script,
and none of the presented ideas so far have helped that.



from ftp(1):
  Note: mget and mput are not meant to transfer entire directory  
subtrees of files. That can be
  done by transferring a tar(1) archive of the subtree (in  binary  
mode).




Re: ftp from script

2009-01-03 Thread Philip Guenther
On Sat, Jan 3, 2009 at 7:27 AM, Ed Ahlsen-Girard eagir...@cox.net wrote:
...
 But my real problem was getting the download to work inside a script,
 and none of the presented ideas so far have helped that.

Perhaps you should actually show the complete output from one that
succeeds and then again from one that fails.  It's hard to help
someone when all you tell us is:
In all cases I see a connection to the server, followed
by a complaint of an invalid directory, and disconnection.

Oh, and please don't anonymize the URLs like you did in your original
post.  For all we know, you're actually using completely different
URLs (purposely or from a typo) and thus completely wasting our time.


Philip Guenther



Re: ftp from script

2009-01-03 Thread eagirard
 johan beisser j...@caustic.org wrote: 
 
 On Jan 3, 2009, at 7:27 AM, Ed Ahlsen-Girard wrote:
 
  You're right.  You're so right, in fact, that I'd already changed the
  code; even I noticed that my original was bad practice.
 
 You're doing this in perl, and not using Net::FTP?
 

I'm starting to think that's the way to do it.

  But my real problem was getting the download to work inside a script,
  and none of the presented ideas so far have helped that.
 
 
 from ftp(1):
Note: mget and mput are not meant to transfer entire directory  
 subtrees of files. That can be
done by transferring a tar(1) archive of the subtree (in  binary  
 mode).
 

I don't want a tree.  The URLs (I thought) pretty clearly showed that I was 
looking for the snaphot files, in the snaphot directory, which is well known 
and does not require recursion.

--
Ed Ahlsen-Girard
Ft. Walton Beach FL



Re: ftp from script

2009-01-03 Thread Karl Karlsson
2009/1/3  eagir...@cox.net:
  johan beisser j...@caustic.org wrote:

 On Jan 3, 2009, at 7:27 AM, Ed Ahlsen-Girard wrote:
 
  You're right.  You're so right, in fact, that I'd already changed the
  code; even I noticed that my original was bad practice.

 You're doing this in perl, and not using Net::FTP?


 I'm starting to think that's the way to do it.

  But my real problem was getting the download to work inside a script,
  and none of the presented ideas so far have helped that.


 from ftp(1):
Note: mget and mput are not meant to transfer entire directory
 subtrees of files. That can be
done by transferring a tar(1) archive of the subtree (in  binary
 mode).


 I don't want a tree.  The URLs (I thought) pretty clearly showed that I was 
 looking for the snaphot files, in the snaphot directory, which is well known 
 and does not require recursion.

 --
 Ed Ahlsen-Girard
 Ft. Walton Beach FL


Must this be doable just from base? Otherwise, just install lftp which
is scriptable in itself and can easily do stuff like mirror, get
whatever.



Re: ftp from script

2009-01-03 Thread Ed Ahlsen-Girard
Philip Guenther wrote:
 On Sat, Jan 3, 2009 at 7:27 AM, Ed Ahlsen-Girard eagir...@cox.net wrote:
 ...
   
 But my real problem was getting the download to work inside a script,
 and none of the presented ideas so far have helped that.
 

 Perhaps you should actually show the complete output from one that
 succeeds and then again from one that fails.  It's hard to help
 someone when all you tell us is:
 In all cases I see a connection to the server, followed
 by a complaint of an invalid directory, and disconnection.

 Oh, and please don't anonymize the URLs like you did in your original
 post.  For all we know, you're actually using completely different
 URLs (purposely or from a typo) and thus completely wasting our time.


 Philip Guenther

   

When I run this:

#!/usr/bin/perl

`cd /home/ed/snap`;

unlink /home/ed/snap/*;

system (ftp, -ia, ftp://rt.fm/pub/OpenBSD/snaphots/i386/*tgz;);
system (ftp, -ia, ftp://rt.fm/pub/OpenBSD/snaphots/i386/INSTALL.i386;);
system (ftp, -ia, ftp://rt.fm/pub/OpenBSD/snaphots/i386/index.txt;); 
system (ftp, -ia, ftp://rt.fm/pub/OpenBSD/snaphots/i386/bsd );
system (ftp, -ia, ftp://rt.fm/pub/OpenBSD/snaphots/i386/bsd.rd;);
system (ftp, -ia, ftp://rt.fm/pub/OpenBSD/snaphots/ports.tar.gz;);

exit;

I get this:


Connected to rt.fm.
220- 
220-  rt.fm   __
220-  Located in Lake in the Hills, Illinois, USA.   |__|__
220-   __|__|__|
220-  Server provided and administrated by Superblock |__|__|
220-  http://superblock.net/ |__|
220- 
220-  100 Mbps connectivity courtesy of DLS Internet
220-  http://dls.net/
220- 
220 quadruple.superblock.net FTP server (Version 6.6/OpenBSD) ready.
331 Guest login ok, send your email address as password.
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
200 Type set to I.
550 pub/OpenBSD/snaphots/i386: No such file or directory.
221 Goodbye.
Connected to rt.fm.
220- 
220-  rt.fm   __
220-  Located in Lake in the Hills, Illinois, USA.   |__|__
220-   __|__|__|
220-  Server provided and administrated by Superblock |__|__|
220-  http://superblock.net/ |__|
220- 
220-  100 Mbps connectivity courtesy of DLS Internet
220-  http://dls.net/
220- 
220 quadruple.superblock.net FTP server (Version 6.6/OpenBSD) ready.
331 Guest login ok, send your email address as password.
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
200 Type set to I.
550 pub/OpenBSD/snaphots/i386: No such file or directory.
221 Goodbye.
Connected to rt.fm.
220- 
220-  rt.fm   __
220-  Located in Lake in the Hills, Illinois, USA.   |__|__
220-   __|__|__|
220-  Server provided and administrated by Superblock |__|__|
220-  http://superblock.net/ |__|
220- 
220-  100 Mbps connectivity courtesy of DLS Internet
220-  http://dls.net/
220- 
220 quadruple.superblock.net FTP server (Version 6.6/OpenBSD) ready.
331 Guest login ok, send your email address as password.
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
200 Type set to I.
550 pub/OpenBSD/snaphots/i386: No such file or directory.
221 Goodbye.
Connected to rt.fm.
220- 
220-  rt.fm   __
220-  Located in Lake in the Hills, Illinois, USA.   |__|__
220-   __|__|__|
220-  Server provided and administrated by Superblock |__|__|
220-  http://superblock.net/ |__|
220- 
220-  100 Mbps connectivity courtesy of DLS Internet
220-  http://dls.net/
220- 
220 quadruple.superblock.net FTP server (Version 6.6/OpenBSD) ready.
331 Guest login ok, send your email address as password.
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
200 Type set to I.
550 pub/OpenBSD/snaphots/i386: No such file or directory.
221 Goodbye.
Connected to rt.fm.
220- 
220-  rt.fm   __
220-  Located in Lake in the Hills, Illinois, USA.   |__|__
220-   __|__|__|
220-  Server provided and administrated by Superblock |__|__|
220-  http://superblock.net/ |__|
220- 
220-  100 Mbps connectivity courtesy of DLS Internet
220-  http://dls.net/
220- 
220 quadruple.superblock.net FTP server (Version 6.6/OpenBSD) ready.
331 Guest login ok, send your email address as password.
230 Guest login ok, access restrictions apply.

Re: ftp from script

2009-01-03 Thread Ed Ahlsen-Girard

Karl Karlsson wrote:

2009/1/3  eagir...@cox.net:
  

 johan beisser j...@caustic.org wrote:


On Jan 3, 2009, at 7:27 AM, Ed Ahlsen-Girard wrote:
  

You're right.  You're so right, in fact, that I'd already changed the
code; even I noticed that my original was bad practice.


You're doing this in perl, and not using Net::FTP?

  

I'm starting to think that's the way to do it.



But my real problem was getting the download to work inside a script,
and none of the presented ideas so far have helped that.


from ftp(1):
   Note: mget and mput are not meant to transfer entire directory
subtrees of files. That can be
   done by transferring a tar(1) archive of the subtree (in  binary
mode).

  

I don't want a tree.  The URLs (I thought) pretty clearly showed that I was 
looking for the snaphot files, in the snaphot directory, which is well known 
and does not require recursion.

--
Ed Ahlsen-Girard
Ft. Walton Beach FL




Must this be doable just from base? Otherwise, just install lftp which
is scriptable in itself and can easily do stuff like mirror, get
whatever.

  
lftp would be fine, although at this opint I'm irritated with the 
problem enough that I want to find out why  my perl isn't getting it done.




Re: ftp from script

2009-01-03 Thread Karl Karlsson
2009/1/3 Ed Ahlsen-Girard eagir...@cox.net:
 Philip Guenther wrote:
 On Sat, Jan 3, 2009 at 7:27 AM, Ed Ahlsen-Girard eagir...@cox.net wrote:
 ...

 But my real problem was getting the download to work inside a script,
 and none of the presented ideas so far have helped that.


 Perhaps you should actually show the complete output from one that
 succeeds and then again from one that fails.  It's hard to help
 someone when all you tell us is:
 In all cases I see a connection to the server, followed
 by a complaint of an invalid directory, and disconnection.

 Oh, and please don't anonymize the URLs like you did in your original
 post.  For all we know, you're actually using completely different
 URLs (purposely or from a typo) and thus completely wasting our time.


 Philip Guenther



 When I run this:

 #!/usr/bin/perl

 `cd /home/ed/snap`;

 unlink /home/ed/snap/*;

 system (ftp, -ia, ftp://rt.fm/pub/OpenBSD/snaphots/i386/*tgz;);
 system (ftp, -ia, ftp://rt.fm/pub/OpenBSD/snaphots/i386/INSTALL.i386;);
 system (ftp, -ia, ftp://rt.fm/pub/OpenBSD/snaphots/i386/index.txt;);
 system (ftp, -ia, ftp://rt.fm/pub/OpenBSD/snaphots/i386/bsd );
 system (ftp, -ia, ftp://rt.fm/pub/OpenBSD/snaphots/i386/bsd.rd;);
 system (ftp, -ia, ftp://rt.fm/pub/OpenBSD/snaphots/ports.tar.gz;);

 exit;

 I get this:


 Connected to rt.fm.
 220-
 220-  rt.fm   __
 220-  Located in Lake in the Hills, Illinois, USA.   |__|__
 220-   __|__|__|
 220-  Server provided and administrated by Superblock |__|__|
 220-  http://superblock.net/ |__|
 220-
 220-  100 Mbps connectivity courtesy of DLS Internet
 220-  http://dls.net/
 220-
 220 quadruple.superblock.net FTP server (Version 6.6/OpenBSD) ready.
 331 Guest login ok, send your email address as password.
 230 Guest login ok, access restrictions apply.
 Remote system type is UNIX.
 Using binary mode to transfer files.
 200 Type set to I.
 550 pub/OpenBSD/snaphots/i386: No such file or directory.
 221 Goodbye.
 Connected to rt.fm.
 220-
 220-  rt.fm   __
 220-  Located in Lake in the Hills, Illinois, USA.   |__|__
 220-   __|__|__|
 220-  Server provided and administrated by Superblock |__|__|
 220-  http://superblock.net/ |__|
 220-
 220-  100 Mbps connectivity courtesy of DLS Internet
 220-  http://dls.net/
 220-
 220 quadruple.superblock.net FTP server (Version 6.6/OpenBSD) ready.
 331 Guest login ok, send your email address as password.
 230 Guest login ok, access restrictions apply.
 Remote system type is UNIX.
 Using binary mode to transfer files.
 200 Type set to I.
 550 pub/OpenBSD/snaphots/i386: No such file or directory.
 221 Goodbye.
 Connected to rt.fm.
 220-
 220-  rt.fm   __
 220-  Located in Lake in the Hills, Illinois, USA.   |__|__
 220-   __|__|__|
 220-  Server provided and administrated by Superblock |__|__|
 220-  http://superblock.net/ |__|
 220-
 220-  100 Mbps connectivity courtesy of DLS Internet
 220-  http://dls.net/
 220-
 220 quadruple.superblock.net FTP server (Version 6.6/OpenBSD) ready.
 331 Guest login ok, send your email address as password.
 230 Guest login ok, access restrictions apply.
 Remote system type is UNIX.
 Using binary mode to transfer files.
 200 Type set to I.
 550 pub/OpenBSD/snaphots/i386: No such file or directory.
 221 Goodbye.
 Connected to rt.fm.
 220-
 220-  rt.fm   __
 220-  Located in Lake in the Hills, Illinois, USA.   |__|__
 220-   __|__|__|
 220-  Server provided and administrated by Superblock |__|__|
 220-  http://superblock.net/ |__|
 220-
 220-  100 Mbps connectivity courtesy of DLS Internet
 220-  http://dls.net/
 220-
 220 quadruple.superblock.net FTP server (Version 6.6/OpenBSD) ready.
 331 Guest login ok, send your email address as password.
 230 Guest login ok, access restrictions apply.
 Remote system type is UNIX.
 Using binary mode to transfer files.
 200 Type set to I.
 550 pub/OpenBSD/snaphots/i386: No such file or directory.
 221 Goodbye.
 Connected to rt.fm.
 220-
 220-  rt.fm   __
 220-  Located in Lake in the Hills, Illinois, USA.   |__|__
 220-   __|__|__|
 220-  Server provided and administrated by Superblock |__|__|
 220-  http://superblock.net/ |__|
 220-
 220-  100 Mbps connectivity courtesy of DLS Internet
 220-  http://dls.net/
 220-
 220 quadruple.superblock.net FTP server (Version 

Re: ftp from script

2009-01-03 Thread Randal L. Schwartz
 Ed == Ed Ahlsen-Girard eagir...@cox.net writes:
Ed #!/usr/bin/perl

Ed `cd /home/ed/snap`;

This doesn't do anything, except waste time.

May I suggest a good book or two for learning perl, so you won't keep
wasting time on this? :)

Might be a good way to learn to check return values as well.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion



Re: ftp from script

2009-01-03 Thread Adriaan
On Sat, Jan 3, 2009 at 4:27 PM, Ed Ahlsen-Girard eagir...@cox.net wrote:

 But my real problem was getting the download to work inside a script,
 and none of the presented ideas so far have helped that.


A simple shell alternative maybe?
-
#!/bin/sh
# -- retrieve snapshot files with a ftp pipeline

DESTDIR=SNAP
mkdir -p ${DESTDIR}

SITE=ftp.caly.nl
SITE=ftp.eu.openbsd.org
DIR=/pub/OpenBSD/snapshots/i386

FILES=
MD5
pxeboot


for THIS in $FILES ; do
   echo Getting file: ${THIS}...
   echo get  ${DIR}/${THIS} ${DESTDIR}/${THIS} | ftp -4ai ${SITE}
   # remote_filename   local_filename
done

ls -l ${DESTDIR}
-
Disadvantage of this type of solution is the repeating ftp logins. If
you are user 99 out of 100 allowed connections for the first file,
you could be locked out haflway if you happen
to become user 101 ;)

ftp(1) is rather scriptable if you use a .netrc file, unfortunately
rather unknown, and thus not beloved..

The following shell script creates a .netrc to do the actual work in
a single ftp session.
-
d
#!/bin/sh
# $Id: snapget,v 1.2 2009/01/04 00:38:09 j65nko Exp $
# get snapshot files with a on the fly generated '.netrc' for ftp(1)

# variables  used in 'netrc' template
# --
ARCH='i386' # architecture name used as ftp dir

RN=44   # used in base${RN}.tgz etc
#VERSION='4.4'  # ftp dir for releases
VERSION='snapshots' # ftp dir for snapshots

DIR=/pub/OpenBSD/${VERSION}/${ARCH}

SITE='ftp.calyx.nl'
SITE='ftp.eu.openbsd.org'

# customizable file sets
# --

#SETS_START
base=
MD5
base${RN}.tgz
bsd
bsd.mp
bsd.rd
comp${RN}.tgz
etc${RN}.tgz
man${RN}.tgz
misc${RN}.tgz


x=
xbase${RN}.tgz
xetc${RN}.tgz
xfont${RN}.tgz
xserv${RN}.tgz
xshare${RN}.tgz


mini=
MD5
base${RN}.tgz
bsd
bsd.rd
etc${RN}.tgz

pxe=
pxeboot


floppy=
floppy${RN}.fs
floppyB${RN}.fs
floppyC${RN}.fs


ALLSETS=base x mini pxe floppy
#SETS_END
# --

if [ $# -eq 0 ] ; then
echo $0: Please specify one or more sets
echo The sets are: ${ALLSETS}
exit 1
fi

# -- accumulate all sets in FILES
for SET in $@ ; do
eval FILES=\\${FILES} \$${SET}\
done

# echo ${FILES} | tr '[:blank:]' '\n'

# -- destination directory
# DESTDIR=SNAP$(date -u +%Y-%m-%d_%H:%M_UTC)
# mkdir ${DESTDIR} || exit 1

DESTDIR=SNAP
mkdir -p SNAP
#echo Destination directory: ${DESTDIR}

# --- 'here document' as '.netrc' template

cat -TEMPLATE ${DESTDIR}/.netrc

machine ${SITE} login anonymous password tha...@puffy.org

macdef init
prompt off
epsv4 off
preserve on
progress on
$( for THIS in ${FILES} ; do
 echo get ${DIR}/${THIS} ${DESTDIR}/${THIS}
   done
)
quit

TEMPLATE

# -- An empty line is the terminator for a macdef macro
# -- So KEEP EMPTY LINE between 'quit' and here document marker 'TEMPLATE'
# -- to prevent 'Macro definition missing null line terminator' messages
# -- from 'ftp'

echo -- Created '.netrc'---
cat -n  $DESTDIR/.netrc
echo --
echo Do you want to start 'ftp' with this '.netrc' ? (Y/N) ; read answer

case $answer in
[Yy] )  ;;

*)  echo $0: I take this for a 'NO', aborting ...
exit 2
;;
esac

# -- ftp uses HOME to locate '.netrc'
env HOME=${DESTDIR} ftp -4 ${SITE} 21 | tee ${DESTDIR}/Logfile

# -- EOF
---
Example of usage:

$ snapget
./snapget: Please specify one or more sets
The sets are: base x mini pxe floppy

$ snapget base x
-- Created .netrc---
 1
 2  machine ftp.eu.openbsd.org login anonymous password tha...@puffy.org
 3
 4  macdef init
 5  prompt off
 6  epsv4 off
 7  preserve on
 8  progress on
 9  get /pub/OpenBSD/snapshots/i386/MD5 SNAP/MD5
10  get /pub/OpenBSD/snapshots/i386/base44.tgz SNAP/base44.tgz
11  get /pub/OpenBSD/snapshots/i386/bsd SNAP/bsd
12  get /pub/OpenBSD/snapshots/i386/bsd.mp SNAP/bsd.mp
13  get /pub/OpenBSD/snapshots/i386/bsd.rd SNAP/bsd.rd
14  get /pub/OpenBSD/snapshots/i386/comp44.tgz SNAP/comp44.tgz
15  get /pub/OpenBSD/snapshots/i386/etc44.tgz SNAP/etc44.tgz
16  get /pub/OpenBSD/snapshots/i386/man44.tgz SNAP/man44.tgz
17  get /pub/OpenBSD/snapshots/i386/misc44.tgz SNAP/misc44.tgz
18  get /pub/OpenBSD/snapshots/i386/xbase44.tgz SNAP/xbase44.tgz
19  get /pub/OpenBSD/snapshots/i386/xetc44.tgz SNAP/xetc44.tgz
20  get /pub/OpenBSD/snapshots/i386/xfont44.tgz SNAP/xfont44.tgz
21  get /pub/OpenBSD/snapshots/i386/xserv44.tgz SNAP/xserv44.tgz
22  get /pub/OpenBSD/snapshots/i386/xshare44.tgz 

Re: ftp from script

2009-01-02 Thread Randal L. Schwartz
 Daniel == Daniel A Ramaley daniel.rama...@drake.edu writes:

Daniel chdir /path-to-dir;

You didn't check the success of the chdir.  This will ruin your original
current directory if that fails...

Daniel unlink *;

Oops!

The proper solution is rmtree, a function defined in File::Path:

  use File::Path;
  rmtree('/path-to-dir');

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion



Re: ftp from script

2008-12-31 Thread Lars Noodén
Ed Ahlsen-Girard wrote:

 Anybody have an idea of what I'm missing?

How is $PATH set?  Do the scripts work if you include the full path?
i.e. /usr/bin/ftp

Regards,
-Lars



Re: ftp from script

2008-12-31 Thread Jesus Sanchez

this works for me, recheck your install, or otherwise
try to compile ftp again from sources.

-Jesus

Ed Ahlsen-Girard escribis:

I'm trying to automate getting the sets and source for running -current.

For some reason, this syntax:

ftp -ia ftp://host.domain/pub/OpenBSD/snapshots/architecture/*.tgz

or this:

ftp -ia ftp://host.domain/pub/OpenBSD/snapshots/architecture/bsd.rd

works great from the command line.  But not in scripts, either shell:

#!/bin/sh

cd /where/I/put/sets

rm *

# all above work fine

ftp -ia ftp://host.domain/pub/OpenBSD/snapshots/architecture/*.tgz

or perl:

#!/usr/bin/perl

`cd /where/I/put/sets`;

`rm *`;

# all above work fine

`ftp -ia ftp://host.domain/pub/OpenBSD/snapshots/architecture/*.tgz`;

Using system () does not get any different behavior, whether I pass a
list or a proper array.  In all cases I see a connection to the 
server, followed

by a complaint of an invalid directory, and disconnection.

I've been using perl for about ten years, and I'm pretty sure my perl 
is ok.

Anybody have an idea of what I'm missing?




Re: ftp from script

2008-12-31 Thread Han Boetes
Ed Ahlsen-Girard wrote:
 I'm trying to automate getting the sets and source for running
 -current.

Incase you don't want to reinvent the wheel:

  http://www.xs4all.nl/~hanb/software/OpenBSD-binary-upgrade/



# Han



Re: ftp from script

2008-12-31 Thread Frank Bax

Ed Ahlsen-Girard wrote:

`ftp -ia ftp://host.domain/pub/OpenBSD/snapshots/architecture/*.tgz`;

Using system () does not get any different behavior, whether I pass a
list or a proper array.  In all cases I see a connection to the server, 
followed by a complaint of an invalid directory, and disconnection.



I don't use snapshots; but I used similar code to get packages.

Why use a list/array?  I use this code to get a single/multiple files 
using wildcards instead.  I made a slight mod to my script to test 
snapshots.


my $get = shift;
system( 'ftp -ia 
ftp://'.$site.'/pub/OpenBSD/'.$ver.'/packages/'.$arch.'/'.$get );


Did you remember to escape the asterisk if passing that into script?

./script \*.tgz



Re: ftp from script

2008-12-31 Thread Christoph Leser
Just my 1 cent on the perl script

#!/usr/bin/perl
`cd /path-to-dir`:
`rm *`;

will purge your working directory, not /path-to-dir, as each of the `command`
constructs is executed  in a process of its own and thus has no influence on
the next command

you would be better of with
#!/usr/bin/perl
`cd /path-to-dir;rm *`;

Regards
Christoph




Von: owner-m...@openbsd.org im Auftrag von Ed Ahlsen-Girard
Gesendet: Mi 31.12.2008 13:27
An: misc@openbsd.org
Betreff: ftp from script



I'm trying to automate getting the sets and source for running -current.

For some reason, this syntax:

ftp -ia ftp://host.domain/pub/OpenBSD/snapshots/architecture/*.tgz

or this:

ftp -ia ftp://host.domain/pub/OpenBSD/snapshots/architecture/bsd.rd

works great from the command line.  But not in scripts, either shell:

#!/bin/sh

cd /where/I/put/sets

rm *

# all above work fine

ftp -ia ftp://host.domain/pub/OpenBSD/snapshots/architecture/*.tgz

or perl:

#!/usr/bin/perl

`cd /where/I/put/sets`;

`rm *`;

# all above work fine

`ftp -ia ftp://host.domain/pub/OpenBSD/snapshots/architecture/*.tgz`;
ftp://host.domain/pub/OpenBSD/snapshots/architecture/*.tgz%60;

Using system () does not get any different behavior, whether I pass a
list or a proper array.  In all cases I see a connection to the server,
followed
by a complaint of an invalid directory, and disconnection.

I've been using perl for about ten years, and I'm pretty sure my perl is ok.
Anybody have an idea of what I'm missing?



Re: ftp from script

2008-12-31 Thread eagirard
That's good thing to know (!)
 Christoph Leser le...@sup-logistik.de wrote: 
 Just my 1 cent on the perl script
  
 #!/usr/bin/perl
 `cd /path-to-dir`:
 `rm *`;
  
 will purge your working directory, not /path-to-dir, as each of the `command` 
 constructs is executed  in a process of its own and thus has no influence on 
 the next command 
  
 you would be better of with
 #!/usr/bin/perl
 `cd /path-to-dir;rm *`;
  
 Regards
 Christoph
  
 
 
 
 Von: owner-m...@openbsd.org im Auftrag von Ed Ahlsen-Girard
 Gesendet: Mi 31.12.2008 13:27
 An: misc@openbsd.org
 Betreff: ftp from script
 
 
 
 I'm trying to automate getting the sets and source for running -current.
 
 For some reason, this syntax:
 
 ftp -ia ftp://host.domain/pub/OpenBSD/snapshots/architecture/*.tgz
 
 or this:
 
 ftp -ia ftp://host.domain/pub/OpenBSD/snapshots/architecture/bsd.rd
 
 works great from the command line.  But not in scripts, either shell:
 
 #!/bin/sh
 
 cd /where/I/put/sets
 
 rm *
 
 # all above work fine
 
 ftp -ia ftp://host.domain/pub/OpenBSD/snapshots/architecture/*.tgz
 
 or perl:
 
 #!/usr/bin/perl
 
 `cd /where/I/put/sets`;
 
 `rm *`;
 
 # all above work fine
 
 `ftp -ia ftp://host.domain/pub/OpenBSD/snapshots/architecture/*.tgz`; 
 ftp://host.domain/pub/OpenBSD/snapshots/architecture/*.tgz%60; 
 
 Using system () does not get any different behavior, whether I pass a
 list or a proper array.  In all cases I see a connection to the server,
 followed
 by a complaint of an invalid directory, and disconnection.
 
 I've been using perl for about ten years, and I'm pretty sure my perl is ok.
 Anybody have an idea of what I'm missing?
 
 
 

--
Ed Ahlsen-Girard
Ft. Walton Beach FL



Re: ftp from script

2008-12-31 Thread bofh
On Wed, Dec 31, 2008 at 9:42 AM, Christoph Leser le...@sup-logistik.de wrote:
 Just my 1 cent on the perl script

 #!/usr/bin/perl
 `cd /path-to-dir`:
 `rm *`;

 will purge your working directory, not /path-to-dir, as each of the `command`
 constructs is executed  in a process of its own and thus has no influence on
 the next command

You shouldn't be using backticks in a perl script.  Backtick simply
starts a new process/subshell and runs whatever you have in the
backticks.  If you're writing perl, use perl's syntax, and you won't
have these issues.


-- 
http://www.glumbert.com/media/shift
http://www.youtube.com/watch?v=tGvHNNOLnCk
This officer's men seem to follow him merely out of idle curiosity.
-- Sandhurst officer cadet evaluation.
Securing an environment of Windows platforms from abuse - external or
internal - is akin to trying to install sprinklers in a fireworks
factory where smoking on the job is permitted.  -- Gene Spafford
learn french:  http://www.youtube.com/watch?v=j1G-3laJJP0feature=related



Re: ftp from script

2008-12-31 Thread eagirard
 On Wed, Dec 31, 2008 at 9:42 AM, Christoph Leser le...@sup-logistik.de 
 wrote:
  Just my 1 cent on the perl script
 
  #!/usr/bin/perl
  `cd /path-to-dir`:
  `rm *`;
 
  will purge your working directory, not /path-to-dir, as each of the 
  `command`
  constructs is executed  in a process of its own and thus has no influence on
  the next command
 
 You shouldn't be using backticks in a perl script.  Backtick simply
 starts a new process/subshell and runs whatever you have in the
 backticks.  If you're writing perl, use perl's syntax, and you won't
 have these issues.
 
 
 --
 http://www.glumbert.com/media/shift
 http://www.youtube.com/watch?v=tGvHNNOLnCk
 This officer's men seem to follow him merely out of idle curiosity.
 -- Sandhurst officer cadet evaluation.
 Securing an environment of Windows platforms from abuse - external or
 internal - is akin to trying to install sprinklers in a fireworks
 factory where smoking on the job is permitted.  -- Gene Spafford
 learn french:  http://www.youtube.com/watch?v=j1G-3laJJP0feature=related

How do you get the output of the command then?  System returns the return value.

Backticks are part of perl's syntax.  See 'perldoc perlop'.

Ed Ahlsen-Girard



Re: ftp from script

2008-12-31 Thread Daniel A. Ramaley
On Wednesday December 31 2008 13:34, you wrote:
On Wed, Dec 31, 2008 at 9:42 AM, Christoph Leser 
le...@sup-logistik.de wrote:
 #!/usr/bin/perl
 `cd /path-to-dir`:
 `rm *`;

You shouldn't be using backticks in a perl script.  Backtick simply
starts a new process/subshell and runs whatever you have in the
backticks.  If you're writing perl, use perl's syntax, and you won't
have these issues.

Try the below instead of the subprocess commands. Verify that unlink 
command first though; i don't work with globs in perl much and might 
have munged the syntax.

chdir /path-to-dir;
unlink *;
-- 

Dan RamaleyDial Center 118, Drake University
Network Programmer/Analyst 2407 Carpenter Ave
+1 515 271-4540Des Moines IA 50311 USA