[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Question about scripting...
On Mon, Aug 10, 2009 at 9:39 AM, scott mcbrien<smcbrien at gmail.com> wrote:
> 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
>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
>
>
Thanks Scott, I am seeing that from the mailing list, the one problem
is I don't know perl well enough to write one. I know bash. But you
can automate the scp in bash, I could do it with expect, but we don't
have expect install on the boxes, so perl was the next choice, I am
currently searching for example of perl script that does this or even
python.
Thanks,
--
----------------------------------------
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