How to pass an argument to encrypted script having openssl ?

Hi,
can it be possible to pass and argument to an encrypted script?

for example.. Say I have this script which takes one input..

> cat aa
#!/bin/ksh

UNAME=$1
echo "Hi $UNAME.."

> aa TEST
Hi TEST..

Now I encrypted this code..

> openssl enc -e -aes-256-cbc -a -in aa > bb
enter aes-256-cbc encryption password:
Verifying - enter aes-256-cbc encryption password:

Then I created one more script to call this encrypted script..

> cat cc
#!/bin/sh
openssl enc -d -aes-256-cbc -a -in bb -pass pass:test123 | sh -

When I ran this like normal script its showing me this error..

> cc TETS
cc: TETS: No such file or directory
cc: no input files

When I ran it without any argument/parameter..

> openssl enc -d -aes-256-cbc -a -in bb -pass pass:unix11 | sh -
Hi ..

How can I pass the argument to such encrypted script..
Thanks..

Well, you should have shown the entire error msg:

cc TETS
cc: error: TETS: No such file or directory
cc: fatal error: no input files
compilation terminated.

which indicates it's a compiler, and indeed, on my system, it's a link to gcc , the GNU C and C++ compiler.

So - be somewhat wary when selecting your script names.

Thanks RudiC.. I have renamed the script.. now I dont have that error.. but still I am not getting the desired output..

> mv cc test_enc
> test_enc
Hi ..
> test_enc AK
Hi ..

I want it should display as..

> test_enc AK
Hi AK ..

Where and how do you supply the parameter to the decrypted script?

> aa AK
Hi AK..
> cat aa
#!/bin/ksh

UNAME=$1
echo "Hi $UNAME.."

Have your test_enc like this:

#!/bin/sh
openssl enc -d -aes-256-cbc -a -in bb -pass pass:test123 | sh -s "$@"
1 Like

Worked perfectly.. MadeInGermany... Thanks a ton...

> cat test_enc
#!/bin/sh
openssl enc -d -aes-256-cbc -a -in bb -pass pass:unix11 | sh -s "$@"

> test_enc MadeInGermany
Hi MadeInGermany..