Hi,
I have a script which adds the user credentials to an ldap server. Im passing the variables as below..
/path/my_script $uname $pwd $environ ${deposit}
If i enter some special characters like ';' in $pwd, script returns an error which is set to display if the user enters insufficient arguments...
i will explain it with an eg:
uname=john
pwd=qwerty;123
environ=student
deposit=1234
So if run
/path/my_script $uname $pwd $environ ${deposit}
itz giving an error which i have set with this condition in my_script
if [ $# -lt 3 ]; then
echo "Error : Insufficient number of arguments"
echo "Usage : $0 username password environment"
echo "Eg : $0 s1corp D56GHxde vault"
exit 0
fi
Can anyone plz help me to sort out this error??
zaxxon
January 29, 2009, 7:21am
2
Try escaping them when being entered by a preceding \ or have every value enclosed by hard single quotes like this:
str\;ing
'str;ing'
So you meant..
/path/my_script $uname '$pwd' $environ ${deposit}
Thatz not working!!??
zaxxon
January 29, 2009, 7:30am
4
No that will not work since the variables can't be substituted inside ' '.
So try using " " around it first.
the values are read from another script and passed over here.. so what modifications can I make with $pwd?? thatz also not working as it is called inside a CGI script like following...
$cmd = "sudo ssh -i /root/.ssh/id_dsa server-fe '/var/www/scripts/my_script $uname $pwd $environ ${deposit}'";
so if i put
$cmd = "sudo ssh -i /root/.ssh/id_dsa server-fe '/var/www/scripts/my_script $uname "$pwd" $environ ${deposit}'";
itz showing internal server error....
zaxxon
January 29, 2009, 8:03am
6
Basically from shell script to shell script:
root@isau02:/data/tmp/testfeld> cat script1.ksh
VAR='abc;123'
./script2.ksh "${VAR}"
root@isau02:/data/tmp/testfeld> cat script2.ksh
echo "$1"
root@isau02:/data/tmp/testfeld> ./script1.ksh
abc;123