[Qt-interest] passing multiple args to rsh encapsulated in a QProcess

Thiago Macieira thiago.macieira at trolltech.com
Wed Aug 26 12:02:04 CEST 2009


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090826/02a8fe16/attachment.bin 


More information about the Qt-interest-old mailing list