<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>RE: Perl digest, Vol 1 #34 - 4 msgs</TITLE>
<META content="MSHTML 5.00.2920.0" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=103343807-20022002>Thanks
all it's working fine.</SPAN></FONT></DIV>
<DIV> </DIV>
<DIV><FONT color=#800000 face="Comic Sans MS" size=2>Rony Sibony</FONT></DIV>
<DIV><FONT color=#800000 face="Comic Sans MS" size=2>+972-51-232031</FONT></DIV>
<DIV><FONT color=#800000 face="Comic Sans MS" size=2>+972-3-6452031</FONT></DIV>
<DIV> </DIV>
<BLOCKQUOTE style="MARGIN-RIGHT: 0px">
<DIV align=left class=OutlookMessageHeader dir=ltr><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Yaron Golan
[mailto:yaron.golan@SeabridgeNetworks.com]<BR><B>Sent:</B> Wednesday, February
20, 2002 9:25 AM<BR><B>To:</B> 'perl@perl.org.il'<BR><B>Subject:</B> [Perl]
RE: Perl digest, Vol 1 #34 - 4 msgs<BR><BR></DIV></FONT>
<P><FONT size=2>you need to escape the spce:</FONT> <BR><FONT size=2>system
("C:\\Program Files\\Windows\ Media\ Player\\wmplayer.exe"</FONT> <BR><FONT
size=2>"\c:\\my_music_file.mp3"");</FONT> </P><BR>
<P><FONT size=2>-----Original Message-----</FONT> <BR><FONT size=2>From:
perl-request@perl.org.il [<A
href="mailto:perl-request@perl.org.il">mailto:perl-request@perl.org.il</A>]</FONT>
<BR><FONT size=2>Sent: Wednesday, February 20, 2002 12:01</FONT> <BR><FONT
size=2>To: perl@perl.org.il</FONT> <BR><FONT size=2>Subject: Perl digest, Vol
1 #34 - 4 msgs</FONT> </P><BR>
<P><FONT size=2>Send Perl mailing list submissions to</FONT>
<BR> <FONT
size=2>perl@perl.org.il</FONT> </P>
<P><FONT size=2>To subscribe or unsubscribe via the World Wide Web,
visit</FONT> <BR> <FONT size=2><A
href="http://www.perl.org.il/cgi/listinfo/perl"
target=_blank>http://www.perl.org.il/cgi/listinfo/perl</A></FONT> <BR><FONT
size=2>or, via email, send a message with subject or body 'help' to</FONT>
<BR> <FONT
size=2>perl-request@perl.org.il</FONT> </P>
<P><FONT size=2>You can reach the person managing the list at</FONT>
<BR> <FONT
size=2>perl-admin@perl.org.il</FONT> </P>
<P><FONT size=2>When replying, please edit your Subject line so it is more
specific</FONT> <BR><FONT size=2>than "Re: Contents of Perl digest..."</FONT>
</P><BR>
<P><FONT size=2>Today's Topics:</FONT> </P>
<P><FONT size=2> 1. run a program in windows (Sibony, Rony)</FONT>
<BR><FONT size=2> 2. Re: run a program in windows (Nimster)</FONT>
<BR><FONT size=2> 3. RE: run a program in windows (Sibony,
Rony)</FONT> <BR><FONT size=2> 4. Re: run a program in windows
(Nimster)</FONT> </P>
<P><FONT size=2>--__--__--</FONT> </P>
<P><FONT size=2>Message: 1</FONT> <BR><FONT size=2>From: "Sibony, Rony"
<Rony_Sibony@icomverse.com></FONT> <BR><FONT size=2>To:
"'perl@perl.org.il'" <perl@perl.org.il></FONT> <BR><FONT size=2>Date:
Tue, 19 Feb 2002 11:16:51 +0200</FONT> <BR><FONT size=2>Subject: [Perl] run a
program in windows</FONT> <BR><FONT size=2>Reply-To: perl@perl.org.il</FONT>
</P><BR>
<P><FONT size=2>Hi All</FONT> </P>
<P><FONT size=2> </FONT> </P>
<P><FONT size=2>I'm a Unix developer so I'm not familiar with perl on
windows.</FONT> </P>
<P><FONT size=2>Maybe someone know how to activate the media player with a
special file that</FONT> <BR><FONT size=2>contain a voice message during the
perl script</FONT> </P><BR>
<P><FONT size=2>Rony Sibony</FONT> <BR><FONT size=2>+972-51-232031</FONT>
<BR><FONT size=2>+972-3-6452031</FONT> <BR><FONT size=2> </FONT> </P>
<P><FONT size=2>--__--__--</FONT> </P>
<P><FONT size=2>Message: 2</FONT> <BR><FONT size=2>Date: Tue, 19 Feb 2002
12:58:44 +0200</FONT> <BR><FONT size=2>From: Nimster
<nimster@netvision.net.il></FONT> <BR><FONT size=2>Subject: Re: [Perl]
run a program in windows</FONT> <BR><FONT size=2>To: perl@perl.org.il</FONT>
<BR><FONT size=2>Reply-To: perl@perl.org.il</FONT> </P>
<P><FONT size=2>></FONT> <BR><FONT size=2>> Hi All</FONT> <BR><FONT
size=2>></FONT> </P>
<P><FONT size=2>Greetings.</FONT> </P>
<P><FONT size=2>></FONT> <BR><FONT size=2>></FONT> <BR><FONT size=2>>
I'm a Unix developer so I'm not familiar with perl on windows.</FONT>
<BR><FONT size=2>></FONT> <BR><FONT size=2>> Maybe someone know how to
activate the media player with a special file</FONT> <BR><FONT
size=2>that</FONT> <BR><FONT size=2>> contain a voice message during the
perl script</FONT> <BR><FONT size=2>></FONT> </P>
<P><FONT size=2>Quite simply, actually. Do a system call for C:\Program
Files\Windows Media</FONT> <BR><FONT size=2>Player\wmplayer.exe
"path\to\file".</FONT> <BR><FONT size=2>This is the default installation path
for WMP. Maybe a registery or</FONT> <BR><FONT size=2>enviroment variable
holds the path for every machine, but I do not know of</FONT> <BR><FONT
size=2>one.</FONT> </P>
<P><FONT size=2>></FONT> <BR><FONT size=2>> Rony Sibony</FONT> <BR><FONT
size=2>> +972-51-232031</FONT> <BR><FONT size=2>> +972-3-6452031</FONT>
<BR><FONT size=2>></FONT> <BR><FONT size=2>>
_______________________________________________</FONT> <BR><FONT size=2>>
Perl mailing list</FONT> <BR><FONT size=2>> Perl@perl.org.il</FONT>
<BR><FONT size=2>> <A href="http://www.perl.org.il/cgi/listinfo/perl"
target=_blank>http://www.perl.org.il/cgi/listinfo/perl</A></FONT> </P><BR>
<P><FONT size=2>--__--__--</FONT> </P>
<P><FONT size=2>Message: 3</FONT> <BR><FONT size=2>From: "Sibony, Rony"
<Rony.Sibony@comverse.com></FONT> <BR><FONT size=2>To:
"'perl@perl.org.il'" <perl@perl.org.il></FONT> <BR><FONT size=2>Subject:
RE: [Perl] run a program in windows</FONT> <BR><FONT size=2>Date: Tue, 19 Feb
2002 15:51:51 +0200</FONT> <BR><FONT size=2>Reply-To: perl@perl.org.il</FONT>
</P>
<P><FONT size=2>I tried this -</FONT> </P>
<P><FONT size=2>system ("C:\\Program Files\\Windows Media
Player\\wmplayer.exe"</FONT> <BR><FONT
size=2>"\c:\\my_music_file.mp3"");</FONT> </P>
<P><FONT size=2>but this one dose'nt working it came out with the error</FONT>
<BR><FONT size=2>'c:\Program' is not recognized as an internal or external
command,</FONT> <BR><FONT size=2>operable program or batch file.</FONT> </P>
<P><FONT size=2>Rony Sibony</FONT> <BR><FONT size=2>+972-51-232031</FONT>
<BR><FONT size=2>+972-3-6452031</FONT> <BR><FONT size=2> </FONT> </P><BR>
<P><FONT size=2>-----Original Message-----</FONT> <BR><FONT size=2>From:
Nimster [<A
href="mailto:nimster@netvision.net.il">mailto:nimster@netvision.net.il</A>]</FONT>
<BR><FONT size=2>Sent: Tuesday, February 19, 2002 12:59 PM</FONT> <BR><FONT
size=2>To: perl@perl.org.il</FONT> <BR><FONT size=2>Subject: Re: [Perl] run a
program in windows</FONT> </P><BR>
<P><FONT size=2>></FONT> <BR><FONT size=2>> Hi All</FONT> <BR><FONT
size=2>></FONT> </P>
<P><FONT size=2>Greetings.</FONT> </P>
<P><FONT size=2>></FONT> <BR><FONT size=2>></FONT> <BR><FONT size=2>>
I'm a Unix developer so I'm not familiar with perl on windows.</FONT>
<BR><FONT size=2>></FONT> <BR><FONT size=2>> Maybe someone know how to
activate the media player with a special file</FONT> <BR><FONT
size=2>that</FONT> <BR><FONT size=2>> contain a voice message during the
perl script</FONT> <BR><FONT size=2>></FONT> </P>
<P><FONT size=2>Quite simply, actually. Do a system call for C:\Program
Files\Windows Media</FONT> <BR><FONT size=2>Player\wmplayer.exe
"path\to\file".</FONT> <BR><FONT size=2>This is the default installation path
for WMP. Maybe a registery or</FONT> <BR><FONT size=2>enviroment variable
holds the path for every machine, but I do not know of</FONT> <BR><FONT
size=2>one.</FONT> </P>
<P><FONT size=2>></FONT> <BR><FONT size=2>> Rony Sibony</FONT> <BR><FONT
size=2>> +972-51-232031</FONT> <BR><FONT size=2>> +972-3-6452031</FONT>
<BR><FONT size=2>></FONT> <BR><FONT size=2>>
_______________________________________________</FONT> <BR><FONT size=2>>
Perl mailing list</FONT> <BR><FONT size=2>> Perl@perl.org.il</FONT>
<BR><FONT size=2>> <A href="http://www.perl.org.il/cgi/listinfo/perl"
target=_blank>http://www.perl.org.il/cgi/listinfo/perl</A></FONT> </P>
<P><FONT size=2>_______________________________________________</FONT>
<BR><FONT size=2>Perl mailing list</FONT> <BR><FONT
size=2>Perl@perl.org.il</FONT> <BR><FONT size=2><A
href="http://www.perl.org.il/cgi/listinfo/perl"
target=_blank>http://www.perl.org.il/cgi/listinfo/perl</A></FONT> </P>
<P><FONT size=2>--__--__--</FONT> </P>
<P><FONT size=2>Message: 4</FONT> <BR><FONT size=2>Date: Tue, 19 Feb 2002
16:56:23 +0200</FONT> <BR><FONT size=2>From: Nimster
<nimster@netvision.net.il></FONT> <BR><FONT size=2>Subject: Re: [Perl]
run a program in windows</FONT> <BR><FONT size=2>To: perl@perl.org.il</FONT>
<BR><FONT size=2>Reply-To: perl@perl.org.il</FONT> </P>
<P><FONT size=2>----- Original Message -----</FONT> <BR><FONT size=2>From:
"Sibony, Rony" <Rony.Sibony@comverse.com></FONT> <BR><FONT size=2>To:
<perl@perl.org.il></FONT> <BR><FONT size=2>Sent: Tuesday, February 19,
2002 3:51 PM</FONT> <BR><FONT size=2>Subject: RE: [Perl] run a program in
windows</FONT> </P><BR>
<P><FONT size=2>> I tried this -</FONT> <BR><FONT size=2>></FONT>
<BR><FONT size=2>> system ("C:\\Program Files\\Windows Media
Player\\wmplayer.exe"</FONT> <BR><FONT size=2>>
"\c:\\my_music_file.mp3"");</FONT> <BR><FONT size=2>></FONT> <BR><FONT
size=2>> but this one dose'nt working it came out with the error</FONT>
<BR><FONT size=2>> 'c:\Program' is not recognized as an internal or
external command,</FONT> <BR><FONT size=2>> operable program or batch
file.</FONT> <BR><FONT size=2>></FONT> </P>
<P><FONT size=2>The answer: system("\"C:\\Program\ Files\\Windows\
Media\</FONT> <BR><FONT size=2>Player\\wmplayer.exe\"\
C:\\my_file.mp3");</FONT> </P>
<P><FONT size=2>Why?: It's windows' cmd.exe that's giving your problems with
the spaces, and</FONT> <BR><FONT size=2>it's windows that needs to be taken
care of with surrounding double-quotes.</FONT> <BR><FONT size=2>Perl passes it
on just as it should. If you type "C:\Program Files\..." in</FONT> <BR><FONT
size=2>the command prompt it will give you the same error.</FONT> </P>
<P><FONT size=2>Another method: You can use Windows shorthands for names over
8.3: trunctate</FONT> <BR><FONT size=2>any spaces, and add ~x where x is the
number of the instance resulting with</FONT> <BR><FONT size=2>the same name,
for example:</FONT> <BR><FONT
size=2>system("C:\\Progra~1\\Window~2\\wmplayer.exe</FONT> <BR><FONT
size=2>\"X:\\Mydocu~1\\Listen\\Robd-c~1.mp3");</FONT> <BR><FONT
size=2>(Robd-c~1.mp3, for example, is Rob D - Clubbed to Death.mp3. Windows
Media</FONT> <BR><FONT size=2>Player is Window~2 because in my case, I have 2
directories which would be</FONT> <BR><FONT size=2>abbriviated to Window~1:
Windows Media Player and Windows NT.)</FONT> </P>
<P><FONT size=2>Interesting bit: from perldoc -f system: "If there is only one
scalar</FONT> <BR><FONT size=2>argument, the argument is checked for shell
metacharacters, and if there are</FONT> <BR><FONT size=2>any, the entire
argument is passed to the system's command shell for parsing</FONT> <BR><FONT
size=2>(this is "/bin/sh -c" on UNIX platforms, but varies on other
platforms</FONT> <BR><FONT size=2>[cmd.exe on windows - Nimster]). If there
are no shell metacharacters in the</FONT> <BR><FONT size=2>argument, it is
split into words and passed directly to "execvp", which is</FONT> <BR><FONT
size=2>more efficient).</FONT> <BR><FONT size=2>This means we can actually
have it work just the same without the</FONT> <BR><FONT size=2>escape-slash
between the command ("C:\Program files\...") and the argument</FONT> <BR><FONT
size=2>("myfile.mp3"). For consistancy, I'd keep it. Besides, it means less
work</FONT> <BR><FONT size=2>for the Perl interperter in splitting the words.
In fact, if we do regard</FONT> <BR><FONT size=2>overhead as much as we
should, we can already use exec() ourselves instead</FONT> <BR><FONT size=2>of
having system() check for meta characters.</FONT> <BR><FONT size=2>One final
word of warning - as a UNIX developer you should know that if you</FONT>
<BR><FONT size=2>give your users the option to type the name of the file, one
malevolent user</FONT> <BR><FONT size=2>might try typing in "& deltree
C:\". I believe that if you indeed use exec()</FONT> <BR><FONT size=2>instead,
it will not be passed to cmd.exe for evaluation of metacharacters,</FONT>
<BR><FONT size=2>and instead wmplayer.exe should return some error on a
missing file. I have</FONT> <BR><FONT size=2>not tried this (yet).</FONT> </P>
<P><FONT size=2>> Rony Sibony</FONT> <BR><FONT size=2>>
+972-51-232031</FONT> <BR><FONT size=2>> +972-3-6452031</FONT> <BR><FONT
size=2>></FONT> <BR><FONT size=2>></FONT> <BR><FONT size=2>></FONT>
</P><BR><BR><BR>
<P><FONT size=2>--__--__--</FONT> </P>
<P><FONT size=2>_______________________________________________</FONT>
<BR><FONT size=2>Perl mailing list</FONT> <BR><FONT
size=2>Perl@perl.org.il</FONT> <BR><FONT size=2><A
href="http://www.perl.org.il/cgi/listinfo/perl"
target=_blank>http://www.perl.org.il/cgi/listinfo/perl</A></FONT> </P><BR>
<P><FONT size=2>End of Perl Digest</FONT> </P></BLOCKQUOTE></BODY></HTML>