[ale] Question about scripting...
Geoffrey
lists at serioustechnology.com
Mon Aug 10 10:12:01 EDT 2009
Matt Rideout wrote:
> My suggestion is to do as much as you can in Perl, and when you do need
> to call a command, use system(). For example:
>
> systems(ls);
That would be:
system(ls);
On the other hand, I prefer the '`' solution because it provides an easy
way to place the output of the command into a variable:
my $lsout = `ls`;
>
> You could accomplish the reverse with perl -e. For example:
>
> perl -e 'print "hello world\n"'
>
> Chuck Payne wrote, On 08/10/2009 08:28 AM:
>> 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
>>
>>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
>
--
Until later, Geoffrey
Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety.
- Benjamin Franklin
More information about the Ale
mailing list