how to reference bash variables inside perl script inside bash script?

Jason Holtzapple ml at bitflip.net
Thu Jun 24 07:21:12 MST 2010


On 06/23/2010 09:44 PM, Steven A. DuChene wrote:

> My problem is I want to be able to pick up $2 from the command line invocation
> of my bash script for the desired password and then pass that into the one line
> perl piece. But with all of the single quotes, double quotes, back ticks and
> etc. I am not able to get the password value in the $2 to be correctly passed
> into the perl one line part of the bash script.
> 
> The core part of the script I am having a problem with looks like:
> 
> #!/bin/bash
> 
> OPASS=$2
> 
> PASS=`perl -e 'print("userPassword: {CRYPT}".crypt("$OPASS","frat-salt")."\n");'`

I'm sure there is some way to get the results that you want with a one
liner, but there's always the option of writing a separate perl script
that takes OPASS as the argument and outputs the encrypted string, which
you can then include in your bash script with command substitution.

--Jason


More information about the PLUG-discuss mailing list