You need to export your variables to have them picked up by sub-processes:
export KEY_NAME=$1
export KEY_CN=$2
题
I got a shell script with 4 variables .So far so good:
#!/bin/bash
echo keygeneration $1 $2 >> /tmp/logfile
touch /home/ubuntu/newproject/static/$1
KEY_NAME=$1
KEY_CN=$1
sh pkitool
there is really nothing complicated about it... I got a Django app which tells the user to type in Username ($1) and Password ($2). when I use the pkitool and give the 2 variables KEY_NAME and KEY_CA a content, it works... when I type in the Username and Password on the website the script even saves the content of the variable and saves it in /static. I can even execute the script itself in my shell when I pass 2 variables.... It looks like this then:
sh keygen.sh FooUsername BarPassword
the only thing that does not work is, when I type in Username and Password in the app, it won't execute the pkitool correctly and the 2 variables KEY_NAME=$1 and KEY_CN=$1 aren't declared.. but that is totally weird because it does save the variable $1 though in static Oo can you guys tell me how this could come ?
解决方案
You need to export your variables to have them picked up by sub-processes:
export KEY_NAME=$1
export KEY_CN=$2