Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

system function and quotation

Posted on 1999-01-21
3
Medium Priority
?
158 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 800 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

916 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