[ale] Question about scripting...

scott mcbrien smcbrien at gmail.com
Mon Aug 10 09:39:48 EDT 2009


Chuck,
You really can't mix together several different languages in the same script
file.  What you can do is write one overarching script that then executes
scripts from other files.  So in the example you provide below, do something
like put your perl bits in another file, and have it take some files as a
command line argument.
 Also, if you want the perl script to run faster, perl has it's own
hostname and date functions, by embedding the shell call for hostname
and date you're having to create a bash process and execute the
`quoted` command for each instance of that command.  On one or two
short runs, probably not a problem, but for things like perl web apps
or other programs that are executed many times, that overhead adds up.

Best Regards,

Scott

On Mon, Aug 10, 2009 at 8:28 AM, Chuck Payne <terrorpup at gmail.com> 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
>
> --
> ----------------------------------------
> Old utilities do not die they just slowly fade away!
> -----------------------------------------
> OpenSUSE -- http://en.opensuse.org/User:Terrorpup
> OpenSuSE Ambassador
> OpenSuSE Member
> Skype -- terrorpup
> twitter -- terrorpup
> _______________________________________________
> 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/6fc4d1c8/attachment.html 


More information about the Ale mailing list