Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-09 Thread Marco van de Voort
In our previous episode, brian said:
 write a batch file for the actual conversions.
 
 
 What are the commands?
 
 mpg321 -q -w tempfile.wav inputfile.mp3
 
 oggenc -Q --output=outputfile.ogg tempfile.wav
 between the ExecuteProcess and fpSystem calls, I just commented out 
 the one I wasn't trying. The two lines of code are
 
   Status := ExecuteProcess(CommandString, ParamString);

That's probably the problem. You use , which might be problematic with
commandline separation and don't offer the commands to exexuteprocess in a
separated matter.

Try 

Status:=ExecuteProcess('/path/to/oggenc',['-Q','--output=outputfile.org','tempfile.wav']);
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-09 Thread michael . vancanneyt



On Fri, 9 Sep 2011, Marco van de Voort wrote:


In our previous episode, brian said:

write a batch file for the actual conversions.


What are the commands?

mpg321 -q -w tempfile.wav inputfile.mp3

oggenc -Q --output=outputfile.ogg tempfile.wav
between the ExecuteProcess and fpSystem calls, I just commented out
the one I wasn't trying. The two lines of code are

Status := ExecuteProcess(CommandString, ParamString);


That's probably the problem. You use , which might be problematic with
commandline separation and don't offer the commands to exexuteprocess in a
separated matter.

Try

Status:=ExecuteProcess('/path/to/oggenc',['-Q','--output=outputfile.org','tempfile.wav']);


You must remove the quotes around 'outputfile.org':

 
Status:=ExecuteProcess('/path/to/oggenc',['-Q','--output=outputfile.org','tempfile.wav']);

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-09 Thread Felipe Monteiro de Carvalho
The quotes are bash commands, they are not part of command line. I
wrote on this topic not long ago, but for TProcess:

http://wiki.lazarus.freepascal.org/Executing_External_Programs#Parameters_which_contain_spaces_.28Replacing_Shell_Quotes.29

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-09 Thread Anton Shepelev
Andrew Haines:

 I  suspect  that  the  oggenc  command  is failing
 because TProcess behind the  scenes  is  splitting
 --output=outputfile.ogg into two params.

Yes, indeed.  It is also mentioned on the WIKI:

   http://wiki.freepascal.org/Executing_External_Programs
   (see section
   Parameters which contain spaces (Replacing Shell Quotes)

While  the  documentation on TProcess and fpExecV is
more ambiguous:


   TProcess:
   If the command to be executed or any  of  the
   arguments  contains  whitespace  (space,  tab
   character, linefeed character) it  should  be
   enclosed in single or double quotes.

   fpExecV:
   In  case  ComLine is a single string, it will
   be split out in an array of  strings,  taking
   into  account  common  whitespace  and  quote
   rules.

Anton
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-09 Thread Marco van de Voort
In our previous episode, Anton Shepelev said:
TProcess:
If the command to be executed or any  of  the
arguments  contains  whitespace  (space,  tab
character, linefeed character) it  should  be
enclosed in single or double quotes.

It should now be possible to pass the parameters to tprocess separated.
I don't remember if that change made it to 2.4.4 though, otherwise it will
be in 2.6.0.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-09 Thread brian

On 09/09/2011 04:02 AM, Felipe Monteiro de Carvalho wrote:

The quotes are bash commands, they are not part of command line. I
wrote on this topic not long ago, but for TProcess:

http://wiki.lazarus.freepascal.org/Executing_External_Programs#Parameters_which_contain_spaces_.28Replacing_Shell_Quotes.29



OK, I've read your notes for TProcess, I'll give that a try. Thanks.

I have to say that when you have two overloaded declarations for 
ExecuteProcess, one with an array of parameters and one with a single 
parameter string, it's not clear to me why you then break the single 
string into individual parameters, but I'm sure there's some good 
reason for it. Maybe that single parameter string form of the command 
should be deprecated. I certainly think that the documentation is 
directly misleading :-


paste

In case ComLine is a single string, it will be split out in an array 
of strings, taking into account common whitespace and quote rules.


/paste

At least IMHO, having to quote the entire parameter string, not just 
the value, is anything but common whitespace and quote rules.


However, thanks again for the assistance, folks. You can be sure this 
one has been carefully noted - the idea of needing to wrap parameter 
AND value in quotes wouldn't have occurred to me in a month of Sundays.



Brian.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-09 Thread Mark Morgan Lloyd

brian wrote:

At least IMHO, having to quote the entire parameter string, not just the 
value, is anything but common whitespace and quote rules.


I am pretty sure that I have had to deal with this in the past on unix, 
writing shell or Perl scripts i.e. not in the context of FPC. It might, 
in the general case, be easier to enforce a rule that filenames don't 
contain characters which have special significance, at which point 
option values aren't going to need to be quoted except for cases like 
OPT= passed to the FPC build.


--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-09 Thread Marco van de Voort
In our previous episode, michael.vancann...@wisa.be said:
 
 You must remove the quotes around 'outputfile.org':
 
   
 Status:=ExecuteProcess('/path/to/oggenc',['-Q','--output=outputfile.org','tempfile.wav']);

While better, this is afaik not required per se, the executing binary can
strip them also while doing cmdline parsing.  It doesn't matter for
executeprocess.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-09 Thread Anton Shepelev
Marco van de Voort:

 It  should  now be possible to pass the parameters
 to tprocess separated.  I don't remember  if  that
 change  made it to 2.4.4 though, otherwise it will
 be in 2.6.0.

Thanks for letting me know.

Is the parameter separation algorithm  intentionally
made   to  split  partially  quoted  arguments  like
'--file=my  file'?   If  not,  then,   maybe   the
StringToPPChar() function should be fixed?

Anton
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-09 Thread Tomas Hajny
On Fri, September 9, 2011 13:40, Marco van de Voort wrote:
 In our previous episode, michael.vancann...@wisa.be said:

 You must remove the quotes around 'outputfile.org':

   
 Status:=ExecuteProcess('/path/to/oggenc',['-Q','--output=outputfile.org','tempfile.wav']);

 While better, this is afaik not required per se, the executing binary can
 strip them also while doing cmdline parsing.  It doesn't matter for
 executeprocess.

Yes, the executing binary can do a lot, but the trouble is that it doesn't
expect that it should need to do that (and thus it probably doesn't do it)
since the Unix shell would probably strip these quotes _if_ the command is
started from shell. That is probably the whole reason why it fails for the
original poster right now.

Tomas


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-09 Thread Felipe Monteiro de Carvalho
On Fri, Sep 9, 2011 at 1:40 PM, Marco van de Voort mar...@stack.nl wrote:
 While better, this is afaik not required per se, the executing binary can
 strip them also while doing cmdline parsing.  It doesn't matter for
 executeprocess.

I wrote that section in the wiki when I had a real issue where the app
did not work if you have quotes in a parameter (I don't remember which
one it was anymore). Similarly I'd suppose that many other
applications won't work with quotes. Maybe some will work

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-09 Thread Jonas Maebe


On 09 Sep 2011, at 13:40, Marco van de Voort wrote:


In our previous episode, michael.vancann...@wisa.be said:


You must remove the quotes around 'outputfile.org':

 Status:=ExecuteProcess('/path/to/oggenc',['-Q','-- 
output=outputfile.org','tempfile.wav']);


While better, this is afaik not required per se, the executing  
binary can

strip them also while doing cmdline parsing.


I don't know any programs other than shells that would do so. FPC  
itself doesn't do anything like that either, and hence would complain  
that it couldn't find a file with such a name (quotes are valid  
characters in file names, at least on Unix-like OSes).


In general, such things are only done if the parameters are passed on  
to a shell, because that one will again process quotes (and then it  
could be required if outputfile.org contains spaces).



Jonas

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-09 Thread Felipe Monteiro de Carvalho
On Fri, Sep 9, 2011 at 1:46 PM, Anton Shepelev anton@gmail.com wrote:
 Is the parameter separation algorithm  intentionally
 made   to  split  partially  quoted  arguments  like
 '--file=my  file'?   If  not,  then,   maybe   the
 StringToPPChar() function should be fixed?

It does not split partially quoted arguments AFAIK Not sure about Free
Pascal Trunk however.

If FPC Trunk also does not support this, then I'm sure a patch to
improve StringToPPChar would be welcome.

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Linux - ExecuteProcess versus fpSystem

2011-09-09 Thread michael . vancanneyt



On Fri, 9 Sep 2011, Marco van de Voort wrote:


In our previous episode, michael.vancann...@wisa.be said:


You must remove the quotes around 'outputfile.org':

  
Status:=ExecuteProcess('/path/to/oggenc',['-Q','--output=outputfile.org','tempfile.wav']);


While better, this is afaik not required per se, the executing binary can
strip them also while doing cmdline parsing.  It doesn't matter for
executeprocess.


In general, you can't expect that from the executing binary. 
It's safe to assume that most don't do this. 
(I've never seen one that does, in fact)


Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal