[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Question about scripting...
- Subject: [ale] Question about scripting...
- From: ecashin at noserose.net (Ed Cashin)
- Date: Mon, 10 Aug 2009 09:51:55 -0400
- In-reply-to: <[email protected]>
- References: <[email protected]>
The question isn't silly, but as others pointed out, there are better
strategies for using multiple technologies. You could, e.g., call
the shell from perl (since perl was designed with that in mind) or
you could put the perl stuff in its own script and then call that from
the shell script.
Folks have said you can't do what you were asking about, though,
which probably goes to far. By adding two lines and fixing the missing
single quote (and commenting out "*nohup*"), your script could be
runnable. The way to do that is to use a here document, as shown
below. I think the example below has low clarity and maintainability,
but it does show one way of doing exactly what you asked about.
Some unsolicited advice I'd offer: It helps to put quotes around
shell variables and to use the "-e" flag so that the shell exits on
encountering an error. Unexpected (and sometimes bad) things
can happen when you let the program get away from you.
#!/bin/bash
set -e
workdir=/tmp
file="`hostname`.`date +%m%d%Y`.tgz"
# Functions
scpjvm () {
/usr/bin/perl -w /dev/stdin <<'EOF'
#!/usr/bin/perl -w
use Net::SFTP;
use strict;
print "hi mom\n";
exit;
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'");
EOF
}
# The work
echo cd $workdir
echo tar czvfpP $file /etc/httpd /opt/jboss/jboss/bin/
echo /opt/jboss/jboss/server /usr/local/bin --exclude *log* --exclude
#*nohup*
scpjvm
rm $file
--
Ed Cashin <ecashin at noserose.net>