On Mon, Aug 10, 2009 at 9:46 AM, Michal Hrusecky
Chuck Payne - 8:27 10.08.09 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.
I would prefer writing it all in shell, but what about something like this:
-------------------------------------------------------------------------- #!/bin/bash
workdir=/tmp file="`hostname`.`date +%m%d%Y`.tgz"
# Functions
scpjvm () {
perl -w << EOF
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'");
EOF
# 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
Chuck, Michal did not highlight that he wrote the perl above as a here-doc, but he did. That is exactly the kind of thing I was saying when I said you need to read up on here-docs. I have used here docs a lot in various scripts, so they are very valuable when trying to write something complex, but self-contained. Greg -- Greg Freemyer Head of EDD Tape Extraction and Processing team Litigation Triage Solutions Specialist http://www.linkedin.com/in/gregfreemyer Preservation and Forensic processing of Exchange Repositories White Paper - http://www.norcrossgroup.com/forms/whitepapers/tng_whitepaper_fpe.html The Norcross Group The Intersection of Evidence & Technology http://www.norcrossgroup.com -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org