[Perl] RE: Perl digest, Vol 1 #34 - 4 msgs

Sibony, Rony Rony.Sibony at comverse.com
Tue Feb 19 23:36:05 PST 2002


Thanks all it's working fine.
 
Rony Sibony
+972-51-232031
+972-3-6452031
 

-----Original Message-----
From: Yaron Golan [mailto:yaron.golan at SeabridgeNetworks.com]
Sent: Wednesday, February 20, 2002 9:25 AM
To: 'perl at perl.org.il'
Subject: [Perl] RE: Perl digest, Vol 1 #34 - 4 msgs



you need to escape the spce: 
system ("C:\\Program Files\\Windows\ Media\ Player\\wmplayer.exe" 
"\c:\\my_music_file.mp3""); 


-----Original Message----- 
From: perl-request at perl.org.il [ mailto:perl-request at perl.org.il
<mailto:perl-request at perl.org.il> ] 
Sent: Wednesday, February 20, 2002 12:01 
To: perl at perl.org.il 
Subject: Perl digest, Vol 1 #34 - 4 msgs 


Send Perl mailing list submissions to 
        perl at perl.org.il 

To subscribe or unsubscribe via the World Wide Web, visit 
        http://www.perl.org.il/cgi/listinfo/perl
<http://www.perl.org.il/cgi/listinfo/perl>  
or, via email, send a message with subject or body 'help' to 
        perl-request at perl.org.il 

You can reach the person managing the list at 
        perl-admin at perl.org.il 

When replying, please edit your Subject line so it is more specific 
than "Re: Contents of Perl digest..." 


Today's Topics: 

   1. run a program in windows (Sibony, Rony) 
   2. Re: run a program in windows (Nimster) 
   3. RE: run a program in windows (Sibony, Rony) 
   4. Re: run a program in windows (Nimster) 

--__--__-- 

Message: 1 
From: "Sibony, Rony" <Rony_Sibony at icomverse.com> 
To: "'perl at perl.org.il'" <perl at perl.org.il> 
Date: Tue, 19 Feb 2002 11:16:51 +0200 
Subject: [Perl] run a program in windows 
Reply-To: perl at perl.org.il 


Hi All 

  

I'm a Unix developer so I'm not familiar with perl on windows. 

Maybe someone know how to activate the media player with a special file that

contain a voice message during the perl script 


Rony Sibony 
+972-51-232031 
+972-3-6452031 
  

--__--__-- 

Message: 2 
Date: Tue, 19 Feb 2002 12:58:44 +0200 
From: Nimster <nimster at netvision.net.il> 
Subject: Re: [Perl] run a program in windows 
To: perl at perl.org.il 
Reply-To: perl at perl.org.il 

> 
> Hi All 
> 

Greetings. 

> 
> 
> I'm a Unix developer so I'm not familiar with perl on windows. 
> 
> Maybe someone know how to activate the media player with a special file 
that 
> contain a voice message during the perl script 
> 

Quite simply, actually. Do a system call for C:\Program Files\Windows Media 
Player\wmplayer.exe "path\to\file". 
This is the default installation path for WMP. Maybe a registery or 
enviroment variable holds the path for every machine, but I do not know of 
one. 

> 
> Rony Sibony 
> +972-51-232031 
> +972-3-6452031 
> 
> _______________________________________________ 
> Perl mailing list 
> Perl at perl.org.il 
> http://www.perl.org.il/cgi/listinfo/perl
<http://www.perl.org.il/cgi/listinfo/perl>  


--__--__-- 

Message: 3 
From: "Sibony, Rony" <Rony.Sibony at comverse.com> 
To: "'perl at perl.org.il'" <perl at perl.org.il> 
Subject: RE: [Perl] run a program in windows 
Date: Tue, 19 Feb 2002 15:51:51 +0200 
Reply-To: perl at perl.org.il 

I tried this - 

system ("C:\\Program Files\\Windows Media Player\\wmplayer.exe" 
"\c:\\my_music_file.mp3""); 

but this one dose'nt working it came out with the error 
'c:\Program' is not recognized as an internal or external command, 
operable program or batch file. 

Rony Sibony 
+972-51-232031 
+972-3-6452031 
  


-----Original Message----- 
From: Nimster [ mailto:nimster at netvision.net.il
<mailto:nimster at netvision.net.il> ] 
Sent: Tuesday, February 19, 2002 12:59 PM 
To: perl at perl.org.il 
Subject: Re: [Perl] run a program in windows 


> 
> Hi All 
> 

Greetings. 

> 
> 
> I'm a Unix developer so I'm not familiar with perl on windows. 
> 
> Maybe someone know how to activate the media player with a special file 
that 
> contain a voice message during the perl script 
> 

Quite simply, actually. Do a system call for C:\Program Files\Windows Media 
Player\wmplayer.exe "path\to\file". 
This is the default installation path for WMP. Maybe a registery or 
enviroment variable holds the path for every machine, but I do not know of 
one. 

> 
> Rony Sibony 
> +972-51-232031 
> +972-3-6452031 
> 
> _______________________________________________ 
> Perl mailing list 
> Perl at perl.org.il 
> http://www.perl.org.il/cgi/listinfo/perl
<http://www.perl.org.il/cgi/listinfo/perl>  

_______________________________________________ 
Perl mailing list 
Perl at perl.org.il 
http://www.perl.org.il/cgi/listinfo/perl
<http://www.perl.org.il/cgi/listinfo/perl>  

--__--__-- 

Message: 4 
Date: Tue, 19 Feb 2002 16:56:23 +0200 
From: Nimster <nimster at netvision.net.il> 
Subject: Re: [Perl] run a program in windows 
To: perl at perl.org.il 
Reply-To: perl at perl.org.il 

----- Original Message ----- 
From: "Sibony, Rony" <Rony.Sibony at comverse.com> 
To: <perl at perl.org.il> 
Sent: Tuesday, February 19, 2002 3:51 PM 
Subject: RE: [Perl] run a program in windows 


> I tried this - 
> 
> system ("C:\\Program Files\\Windows Media Player\\wmplayer.exe" 
> "\c:\\my_music_file.mp3""); 
> 
> but this one dose'nt working it came out with the error 
> 'c:\Program' is not recognized as an internal or external command, 
> operable program or batch file. 
> 

The answer: system("\"C:\\Program\ Files\\Windows\ Media\ 
Player\\wmplayer.exe\"\ C:\\my_file.mp3"); 

Why?: It's windows' cmd.exe that's giving your problems with the spaces, and

it's windows that needs to be taken care of with surrounding double-quotes. 
Perl passes it on just as it should. If you type "C:\Program Files\..." in 
the command prompt it will give you the same error. 

Another method: You can use Windows shorthands for names over 8.3: trunctate

any spaces, and add ~x where x is the number of the instance resulting with 
the same name, for example: 
system("C:\\Progra~1\\Window~2\\wmplayer.exe 
\"X:\\Mydocu~1\\Listen\\Robd-c~1.mp3"); 
(Robd-c~1.mp3, for example, is Rob D - Clubbed to Death.mp3. Windows Media 
Player is Window~2 because in my case, I have 2 directories which would be 
abbriviated to Window~1: Windows Media Player and Windows NT.) 

Interesting bit: from perldoc -f system: "If there is only one scalar 
argument, the argument is checked for shell metacharacters, and if there are

any, the entire argument is passed to the system's command shell for parsing

(this is "/bin/sh -c" on UNIX platforms, but varies on other platforms 
[cmd.exe on windows - Nimster]). If there are no shell metacharacters in the

argument, it is split into words and passed directly to "execvp", which is 
more efficient). 
This means we can actually have it work just the same without the 
escape-slash between the command ("C:\Program files\...") and the argument 
("myfile.mp3"). For consistancy, I'd keep it. Besides, it means less work 
for the Perl interperter in splitting the words. In fact, if we do regard 
overhead as much as we should, we can already use exec() ourselves instead 
of having system() check for meta characters. 
One final word of warning - as a UNIX developer you should know that if you 
give your users the option to type the name of the file, one malevolent user

might try typing in "& deltree C:\". I believe that if you indeed use exec()

instead, it will not be passed to cmd.exe for evaluation of metacharacters, 
and instead wmplayer.exe should return some error on a missing file. I have 
not tried this (yet). 

> Rony Sibony 
> +972-51-232031 
> +972-3-6452031 
> 
> 
> 




--__--__-- 

_______________________________________________ 
Perl mailing list 
Perl at perl.org.il 
http://www.perl.org.il/cgi/listinfo/perl
<http://www.perl.org.il/cgi/listinfo/perl>  


End of Perl Digest 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://perl.org.il/pipermail/perl/attachments/20020220/e7edbdc9/attachment.htm 


More information about the Perl mailing list