[ale] Question about scripting...
JK
jknapka at kneuro.net
Mon Aug 10 09:49:14 EDT 2009
As Geoffrey says, there's no existing way to do this, although some folks
are working on something called "UPL" which seems, well, overly-complicated
to me: http://wiki.tcl.tk/13292
What you can do, though, is write scripts in different languages and then
use a Bash script to glue them all together:
--- File hello.py
#!/usr/bin/python
print "Hello"
--- File commaSpace.tcl
#!/usr/bin/tclsh
echo ", "
-- File world.sh
#!/bin/bash
echo "world!"
-- Main script:
#!/bin/bash
# Note: The Bash syntax $(command) runs "command" and captures the output.
HELLO=$(hello.py)
CS=$(commaSpace.tcl)
WORLD=$(world.sh)
echo ${HELLO}${CS}${WORLD}
-- JK
Chuck Payne 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
>
More information about the Ale
mailing list