I mix bash with other langs all the time. There are 2.1 techniques to master and you will scripting like pro in no time.<br><br>First, I&#39;ll go ahead and point out the obvious: What you have shown in your example is a very unnecessary use of Perl. You should just be using the scp command with public key authentication rather than passwords. But, lets move past that because the desire to mix things like this is very valid. For example, I mix bash+awk and bash+sed all the time. I highly recommend everyone keep the bash heredoc tests handy <a href="http://src.opensolaris.org/source/xref/sfw/usr/src/cmd/bash/bash-3.2/tests/heredoc.tests">http://src.opensolaris.org/source/xref/sfw/usr/src/cmd/bash/bash-3.2/tests/heredoc.tests</a> (as open solaris adopts newer versions of bash the 3.2 will change a simple <a href="http://www.google.com/search?q=bash+heredoc+tests+opensolaris">http://www.google.com/search?q=bash+heredoc+tests+opensolaris</a> will find the new one)<br>
<br>#Technique 1#<br>Use quoted/escaped scripts (aka: progs or commands) passed as an argument. This is supported by most languages. You can find it in the SYNOPSIS of most man pages. Here are a few examples:<br>    perl -e &#39;command&#39;<br>
    awk &#39;prog&#39;<br>    sed -e &#39;script&#39;<br>    mysql -e &#39;statement&#39;<br>(Using -e for this is pretty common. Notice that awk is the odd man out here.) The problem is that if you quote your script with double quotes, you must escape all double quotes (and $var names that you don&#39;t want bash to expand, but rather pass to perl) within it. If you use single quotes, no bash expansion happens and you cannot escape out single quotes within. (That warrants repeating.) You cannot escape single quotes with single quotes in bash. You will go crazy trying: echo &#39;It\&#39;s never going to work.&#39; This technique is find for oneliners and awk, but get tedious very quickly. This is well suited for awk because it only uses double quotes as far as I&#39;ve ever seen. I shared an example of this with my team just this morning: <a href="http://dpaste.com/77724/">http://dpaste.com/77724/</a> The example on line 7 should work for anyone, the one on line 3 uses servers that are not public. You may have to change gawk to awk, depending on your platform.<br>
<br>#Technique 2#<br>Use bash heredoc syntax to feed your script into stdin. This will not work, however if your script needs to process stdin, for that jump to technique 2.1 below. Most script interpreters that accept a script file as a command line argument will interpret a hyphen &quot;-&quot; as an alias for stdin. Examples:<br>
python - &lt;&lt; EOF<br>print  &quot;It&#39;s good!&quot;<br>print &quot;my home is $HOME&quot;<br>
EOF<br><br>perl - &lt;&lt; &#39;EOF&#39;<br>
# notice the use of single quotes to protect this heredoc from bash expansion<br>my $msg  = &quot;It&#39;s good!&quot;;<br>
print $msg;EOF<br><br>
(mysql expect stdin to be a script by default)<br>mysql &lt;&lt; EOF<br>mysql -u root -p &lt;&lt; EOF<br>select now(), &#39;$(date)&#39;, &#39;$HOME&#39;;<br># notice that even subshells or back ticks can be used<br>EOF<br>
<br>#Technique 2.1&quot;<br>Use heredoc syntax to create your script as a temporary file and delete it after execution. Why would you do this instead of just have 2 files? So that your script has its requirements build in, and you can easily share it with other members of your team. If having everything in one file wasn&#39;t beneficial, we wouldn&#39;t have .tar, .jars, .egg, .gem, etc.<br>
<br>tmp=$(mktemp)<br>cat &gt;$tmp&lt;&lt;&#39;EOF&#39;<br>s/bad/good/<br>EOF<br>rm $tmp<br><br>echo &quot;It&#39;s bad&quot; | perl -p -i -f  $tmp<br><br>I know it&#39;s overwhelming, but it works. I hope someone finds this useful. I expect someone will since I saw a bunch of &quot;you can&#39;t do that&quot; replies come in while I wrote this.<br>
<br>I have modified your script below to use technique 2.1 I haven&#39;t tested it though. Enjoy.<br><br><div class="gmail_quote">On Mon, Aug 10, 2009 at 8:28 AM, Chuck Payne <span dir="ltr">&lt;<a href="mailto:terrorpup@gmail.com">terrorpup@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Sorry if this question seem a bit silly, but I am still very much a<br>
newbie when it come some to scripting.<br>
<br>
I want to write a shell script that does some scp of files, but I like<br>
to use both bash and perl. Could I do some thing this,  how would I<br>
got about mixing shell, python, perl and other things with in a<br>
script.<br>
<br></blockquote>
#!/bin/bash<br>
<br>
workdir=/tmp<br>
file=&quot;`hostname`.`date +%m%d%Y`.tgz&quot;<br>
<br>
# Functions<br>
<br>
scpjvm () {<br>
<br>tmp=$(mktemp)<br>
cat &gt;$tmp&lt;&lt;&#39;EOF&#39;<br>

use Net::SFTP;<br>
use strict;<br>
<br>
my $host = &quot;<a href="http://mars.myhost.com" target="_blank">mars.myhost.com</a>&quot;;<br>
my %args = (<br>
    user =&gt; &#39;toor,<br>
    password =&gt; &#39;1234567&#39;,<br>
    debug =&gt; &#39;true&#39;<br>
);<br>
<br>
my $sftp = Net::SFTP-&gt;new($host, %args);<br>
$sftp-&gt;get(&quot;/tmp/&#39;jvm.`hostname`.`date +%m%d%Y`.tgz&#39;&quot;,<br>
&quot;/home/ia/&#39;jvm.`hostname`.`date +%m%d%Y`.tgz&#39;&quot;);<br>
EOF<br><br>/usr/bin/perl -f $tmp<br>
rm $tmp<br><br>
}<br>
<br>
# The work<br>
<br>
cd $workdir<br>
<br>
tar czvfpP $file  /etc/httpd /opt/jboss/jboss/bin/<br>
/opt/jboss/jboss/server /usr/local/bin --exclude *log* --exclude<br>
*nohup*<br>
<br>
scpjvm<br>
<br>
rm  $file<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
--<br>
----------------------------------------<br>
Old utilities do not die they just slowly fade away!<br>
-----------------------------------------<br>
OpenSUSE -- <a href="http://en.opensuse.org/User:Terrorpup" target="_blank">http://en.opensuse.org/User:Terrorpup</a><br>
OpenSuSE Ambassador<br>
OpenSuSE Member<br>
Skype -- terrorpup<br>
twitter -- terrorpup<br>
_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>.!# RichardBronosky #!.<br>