Solved

system function and quotation

Posted on 1999-01-21
3
149 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
Comment Utility
escape the " using \...
i.e.
system("useradd -g users /home/the_name -c \"$VARIABLE\" ....")

0
 

Author Comment

by:cl071997
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now