Home pass bash script args as named parameters to a command inside the script
Reply: 0

pass bash script args as named parameters to a command inside the script

user917
1#
user917 Published in June 23, 2018, 7:53 am

I have a bash script that takes two parameters. Inside that script, I need to call ssh using a heredoc and call a method that expects the two arguments. For example:

ssh -o "IdentitiesOnly=yes" -t -i $key -l user localhost << 'ENDSSH'
/my_python_app.py -u -t tar -p $1 -f $2
ENDSSH

key is set by my script, I know that part is good.

However, my_python_app prints out args and it doesn't show any arguments for -p and -f

I would call my script like

my_script /tmp filename

I use argparse in my python app, but I am also printing out sys.argv and it gives me:

['my_python_app.py', '-u', '-t', 'tar', '-p', '-f']

Note there are no values received for -p and -f. (-u is a flag, and that is set correctly).

How do I pass $1 and $2 to my_python_app as the -p and -f values?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.311077 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO