Solved

system function and quotation

Posted on 1999-01-21
3
152 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:cl071997
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
ptruman earned 200 total points
ID: 1832370
escape the " using \...
i.e.
system("useradd -g users /home/the_name -c \"$VARIABLE\" ....")

0
 

Author Comment

by:cl071997
ID: 1832371
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
0
 

Author Comment

by:cl071997
ID: 1832372
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\" .......
!
");
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question