[Qt-interest] passing multiple args to rsh encapsulated in a QProcess
Sarvesh Saran
Sarvesh.Saran at synopsys.com
Wed Aug 26 14:02:02 CEST 2009
Hi,
Thanks for the reply. unfortunately your suggestion did not work...it could be because of the nature of the argument..
I will first show the C equivalent of the command which is used in a system command and works fine.
char *buf = "rsh machine1 \"source /remote/bin/settings.csh\";qhost"
fprintf(stderr,"%d\n",system(buf));
the above works fine..
its QT equivalent would be:
QString str = QString("\"source /remote/bin/settings.csh\";qhost);
args<<"machine1"<<str;
process->start("rsh",args);
this however does not work...
Thanks,
Sarvesh
-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Thiago Macieira
Sent: Wednesday, August 26, 2009 3:32 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] passing multiple args to rsh encapsulated in a QProcess
Em Quarta-feira 26 Agosto 2009, às 09:00:52, Sarvesh Saran escreveu:
> Hi,
>
> I am trying to invoke RSH In a QProcess and would like to pass
> multiple commands to RSH ( Linux OS). The following code works:
>
> QProcess *process = new QProcess(this); QStringList args; args
> <<"machine1"<<"ls";
> process->start("rsh",args);
>
> As you can see RSH here is passed only a single command "ls"
>
>
> However this does not seem to work.
>
> args<<"machine1"<<". /mypath/settings.sh"<<";mycommand";
>
> process->start("rsh",args);
>
> (on the command line the above command works fine..i.e. rsh machine1
> "./mypath/settings.sh;mycommand").
The equivalent of shell:
rsh machine1 "./mypath/settings.sh;mycommand"
is:
args << "machine1" << "./mypath/settings.sh;mycommand";
What happens is that the double-quotes (") in the shell make most special characters lose their special meaning. What's important for us is that spaces no longer separate arguments and ; no longer terminates the command.
That means the "./mypath/settings.sh;mycommand" argument is passed as a single argument to the process (without the quotes). That's what you need to replicate in QProcess.
--
Thiago Macieira - thiago.macieira (AT) nokia.com
Senior Product Manager - Nokia, Qt Development Frameworks
Sandakerveien 116, NO-0402 Oslo, Norway
Qt Developer Days 2009 | Registration Now Open!
Munich, Germany: Oct 12 - 14 San Francisco, California: Nov 2 - 4
http://qt.nokia.com/qtdevdays2009
More information about the Qt-interest-old
mailing list