[ale] Question about scripting...

Jerald Sheets questy at gmail.com
Mon Aug 10 13:00:34 EDT 2009


You should look into using the rsync cpan module.

http://search.cpan.org/~leakin/File-Rsync-0.42/Rsync.pm

Not only can you keep it all in perl-land, but you can use your already
generated script as source material for your new perl script that "does it
all".

A few ssh keys and some creative rsyncing, and you can manage just about
anything.  Also, if you want to run interactively, you can use Expect.pm and
do it in an automated fashion:

http://search.cpan.org/~rgiersig/Expect-1.21/Expect.pod


Hope that helps!

---
Jerald M. Sheets jr.


On Mon, Aug 10, 2009 at 11:34 AM, Tim Watts <timtw at earthlink.net> wrote:

> Another way to mix bash & perl uses perl's -x option and __END__.
>
> The nice thing here is you don't have to worry about quoting so much. See
> man
> perlrun for more details.
>
> #!/bin/bash
>
> echo "This is from bash"
> perl -x $0 "$@"
> echo "back to bash"
> exit 0;
>
> #!perl
> use English;
> use strict;
>
> print "This is from perl\n";
>
> my $a;
> foreach $a (@ARGV) {
>  print "arg: $a\n";
> }
>
> __END__
>
>
> Be sure to exit in the bash portion before you hit #!perl or bash will
> start
> complaining. __END__ is not strictly necessary if nothing follows it in the
> file.
>
>
> On Monday 10 August 2009 8:28:18 am Chuck Payne wrote:
> > Sorry if this question seem a bit silly, but I am still very much a
> > newbie when it come some to scripting.
> >
> > I want to write a shell script that does some scp of files, but I like
> > to use both bash and perl. Could I do some thing this,  how would I
> > got about mixing shell, python, perl and other things with in a
> > script.
> >
> > #!/bin/bash
> >
> > workdir=/tmp
> > file="`hostname`.`date +%m%d%Y`.tgz"
> >
> > # Functions
> >
> > scpjvm () {
> >
> > #!/usr/bin/perl -w
> >
> > use Net::SFTP;
> > use strict;
> >
> > my $host = "mars.myhost.com";
> > my %args = (
> >     user => 'toor,
> >     password => '1234567',
> >     debug => 'true'
> > );
> >
> > my $sftp = Net::SFTP->new($host, %args);
> > $sftp->get("/tmp/'jvm.`hostname`.`date +%m%d%Y`.tgz'",
> > "/home/ia/'jvm.`hostname`.`date +%m%d%Y`.tgz'");
> >
> >
> > }
> >
> > # The work
> >
> > cd $workdir
> >
> > tar czvfpP $file  /etc/httpd /opt/jboss/jboss/bin/
> > /opt/jboss/jboss/server /usr/local/bin --exclude *log* --exclude
> > *nohup*
> >
> > scpjvm
> >
> > rm  $file
>
> --
> It is the final proof of God's omnipotence that he need not exist in order
> to
> save us.
>  -- Peter De Vries
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20090810/799fbfd6/attachment.html 


More information about the Ale mailing list