Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

system function and quotation

Posted on 1999-01-21
3
Medium Priority
?
155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 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