Confusion with quoted strings in system() arguments 
Author Message
 Confusion with quoted strings in system() arguments

Why are these two system calls not the same?
The first one works but the second one does not.  I thought
they would be syntactically the same, but the second one
fails with "The filename, directory name, or volume label
syntax is incorrect."

(ActiveState Perl 5.6.0 on Windows NT)

---------------
$Prog = "C:\\WinNt\\Notepad.exe";
$File = "C:\\My Documents\\Temp\\sometext.xxx";


# system ( "\"$Prog\"", "\"$File\"" ) ;



Tue, 28 Jan 2003 03:00:00 GMT  
 Confusion with quoted strings in system() arguments

Quote:

> Sent: Friday, August 11, 2000 07:50

> Subject: Confusion with quoted strings in system() arguments

> Why are these two system calls not the same?

Those are not 'system calls'; they are calls to the system() function.
A 'system call' requests a service from the operating system, for
example opening or printing to a file.

Quote:
> The first one works but the second one does not.  I thought
> they would be syntactically the same, but the second one
> fails with "The filename, directory name, or volume label
> syntax is incorrect."

> (ActiveState Perl 5.6.0 on Windows NT)

> ---------------
> $Prog = "C:\\WinNt\\Notepad.exe";
> $File = "C:\\My Documents\\Temp\\sometext.xxx";




When in doubt, print it out!  Replace 'system' by 'print' to see what
the argument string is.

Look, ma, no double-quotes!

Quote:
> # system ( "\"$Prog\"", "\"$File\"" ) ;

But that one does have double-quotes explicitly.

There are several ways to fix this.  Here is a simple one:

  $Prog = '"C:\WinNt\Notepad.exe"';
  $File = '"C:\My Documents\Temp\sometext.xxx"';
  ...

--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/



Tue, 28 Jan 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. adding field to the main index

2. quoting confusion in system calls

3. changing a single quote string to a double quote string

4. Converting single quoted string to double quoted string

5. need TP higher then 5.5

6. quote & print confusion

7. PERLFUNC: qx/STRING/ - backquote quote a string

8. PERLFUNC: qq/STRING/ - doubly quote a string

9. PERLFUNC: q/STRING/ - singly quote a string

10. PERLFUNC: qx/STRING/ - backquote quote a string

11. PERLFUNC: qq/STRING/ - doubly quote a string

12. PERLFUNC: q/STRING/ - singly quote a string

 

 
Powered by phpBB® Forum Software