Mailinglist Archive: opensuse (1556 mails)

< Previous Next >
Re: [opensuse] Question about scripting...
  • From: Michal Hrusecky <mhrusecky@xxxxxxx>
  • Date: Mon, 10 Aug 2009 15:46:26 +0200
  • Message-id: <20090810134626.GA25224@xxxxxxxxxxxxxxxxxxxxxxxxxx>
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

--------------------------------------------------------------------------

--
Michal Hrusecky

Package Maintainer
SUSE LINUX, s.r.o
e-mail: mhrusecky@xxxxxxx
< Previous Next >
References