Link to home
Start Free TrialLog in
Avatar of cl071997
cl071997

asked on

system function and quotation

Hi
I got some problem with doublequotes.
Here it is:
system("useradd -g users /home/the_name -c $VARIABLE ....")
The $VARIABLE is a name with at least two words, which the systems thinks is two arguments. I tried to put "" or '' around the $VARIABLE, but no...
How do I solve it?
Greatful
Classe
Sweden
ASKER CERTIFIED SOLUTION
Avatar of ptruman
ptruman

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cl071997
cl071997

ASKER

Yes it works, great.
But I forgot to show you the whole example, sorry. here it is:
system("remsh $SERVERNAME /usr/bin/useradd -g users -c \"$USER_NAME\" ...")
remsh = HP-UX remote shell.
My first question is answered. Consider this comment as just a comment. Do you know the answer of this comment - great, if not, I´m satisfied and I will try to connect HP for some solution.
Thanks
Classe
YES! I got it!
If you run the system() like this - it works.
system("remsh $SERVER /bin/sh<<!
#now im working remote, not just sending remote commond (so to speak)
/usr/sbin/useradd -g users -d /home/$NAME -c \"$COMMENTS\" .......
!
");