* Executing a perl script from Windows 7 @ 2014-03-09 19:22 Peter Holsberg 2014-03-09 20:16 ` Max Polk ` (2 more replies) 0 siblings, 3 replies; 6+ messages in thread From: Peter Holsberg @ 2014-03-09 19:22 UTC (permalink / raw) To: cygwin Hi, I have a perl script that I would like to execute simply by double-clicking on its name from a Windows filemanager window. (That is, I do not want to use the command line at all, nor do I want to use an icon.) Eg, myscript.pl I tried using this #!C:\cygwin64\bin\perl.exe as the first line in the script but when I double-click the script, Windows opens it in a text editor. (I suppose I have .pl associated with that editor!) How do I fix this? Thanks. -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Executing a perl script from Windows 7 2014-03-09 19:22 Executing a perl script from Windows 7 Peter Holsberg @ 2014-03-09 20:16 ` Max Polk 2014-03-09 21:50 ` Peter Holsberg 2014-03-16 0:00 ` Reini Urban 2014-03-20 15:02 ` Linda Walsh 2 siblings, 1 reply; 6+ messages in thread From: Max Polk @ 2014-03-09 20:16 UTC (permalink / raw) To: cygwin On 3/9/2014 2:08 PM, Peter Holsberg wrote: > I have a perl script that I would like to execute simply by > double-clicking on its name from a Windows filemanager window. (That > is, I do not want to use the command line at all, nor do I want to use > an icon.) > > Eg, myscript.pl > > I tried using this > > #!C:\cygwin64\bin\perl.exe Windows does not pay attention to file contents (like the first line in your example), only the file name. If you don't want a file association, you can opt to simply create a shortcut to your script that begins with the python executable and that lists the script as a parameter. -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Executing a perl script from Windows 7 2014-03-09 20:16 ` Max Polk @ 2014-03-09 21:50 ` Peter Holsberg 2014-03-10 2:25 ` Andrey Repin 0 siblings, 1 reply; 6+ messages in thread From: Peter Holsberg @ 2014-03-09 21:50 UTC (permalink / raw) To: cygwin On 3/9/2014 2:18 PM, Max Polk wrote: > On 3/9/2014 2:08 PM, Peter Holsberg wrote: >> I have a perl script that I would like to execute simply by >> double-clicking on its name from a Windows filemanager window. (That >> is, I do not want to use the command line at all, nor do I want to use >> an icon.) >> >> Eg, myscript.pl >> >> I tried using this >> >> #!C:\cygwin64\bin\perl.exe > > Windows does not pay attention to file contents (like the first line in > your example), only the file name. If you don't want a file > association, you can opt to simply create a shortcut to your script that > begins with the python executable and that lists the script as a parameter. A file association to what, .pl to perl.exe? Well, a shortcut would be a desktop icon, wouldn't it? Why did you mention python? Thanks. -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Executing a perl script from Windows 7 2014-03-09 21:50 ` Peter Holsberg @ 2014-03-10 2:25 ` Andrey Repin 0 siblings, 0 replies; 6+ messages in thread From: Andrey Repin @ 2014-03-10 2:25 UTC (permalink / raw) To: Peter Holsberg, cygwin Greetings, Peter Holsberg! >>> I have a perl script that I would like to execute simply by >>> double-clicking on its name from a Windows filemanager window. (That >>> is, I do not want to use the command line at all, nor do I want to use >>> an icon.) >>> >>> Eg, myscript.pl >>> >>> I tried using this >>> >>> #!C:\cygwin64\bin\perl.exe >> >> Windows does not pay attention to file contents (like the first line in >> your example), only the file name. If you don't want a file >> association, you can opt to simply create a shortcut to your script that >> begins with the python executable and that lists the script as a parameter. > A file association to what, .pl to perl.exe? To a shell script like ----8<--------8<--------8<--------8<--------8<--------8<--------8<---- #!/bin/sh test -z "$1" && exit 1 env "$( cygpath -au "$1")" "${@:2}" ---->8-------->8-------->8-------->8-------->8-------->8-------->8---- Then just link all extensions you want to exec through cygwin to this file type. I.e. > ftype unixshell.script unixshell.script="C:\Programs\Cygwin\bin\env.exe" /bin/cygwrap.sh "%1" %* > assoc .sh .sh=unixshell.script > Well, a shortcut would be a desktop icon, wouldn't it? Depends. There's a way to make it through "Send to" menu. Then you could even run scripts without extension. > Why did you mention python? It's irrelevant. -- WBR, Andrey Repin (anrdaemon@yandex.ru) 10.03.2014, <01:41> Sorry for my terrible english... -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Executing a perl script from Windows 7 2014-03-09 19:22 Executing a perl script from Windows 7 Peter Holsberg 2014-03-09 20:16 ` Max Polk @ 2014-03-16 0:00 ` Reini Urban 2014-03-20 15:02 ` Linda Walsh 2 siblings, 0 replies; 6+ messages in thread From: Reini Urban @ 2014-03-16 0:00 UTC (permalink / raw) To: The Cygwin Mailing List perl core has a script called pl2bat.pl to create an executable bat file. It's in win32/bin/pl2bat.pl See http://perl5.git.perl.org/perl.git/blob_plain/HEAD:/win32/bin/pl2bat.pl -- Reini Urban http://cpanel.net/ http://www.perl-compiler.org/ -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Executing a perl script from Windows 7 2014-03-09 19:22 Executing a perl script from Windows 7 Peter Holsberg 2014-03-09 20:16 ` Max Polk 2014-03-16 0:00 ` Reini Urban @ 2014-03-20 15:02 ` Linda Walsh 2 siblings, 0 replies; 6+ messages in thread From: Linda Walsh @ 2014-03-20 15:02 UTC (permalink / raw) To: Peter Holsberg, cygwin Peter Holsberg wrote: > Hi, > > I have a perl script that I would like to execute simply by > double-clicking on its name from a Windows filemanager window. > I tried using this: > #!C:\cygwin64\bin\perl.exe > > as the first line in the script but when I double-click the script, > Windows opens it in a text editor. (I suppose I have .pl associated with > that editor!) ---- Sorry for late reply, you probably already have this solved. But if you wanted to do it through Explorer... A simple way... but it won't open in your text editor anymore, Open Explorer and goto a directory with a .pl extension in it. hover over it so it is selected (but you don't want to open it). (I say "over", as I have "single-click to open", like links, and hover selects). then at the top of the Explorer window below the optional address and command bars, you should see a line that has things like: Organize Open â¼ Print E-mail Burn New folder Click on the triangle by open it should give you a choice menu. Goto Choose default program... (bottom line). For you, it looks like you have cygwin in cygwin64, so in there you can *Browse*, for perl.exe, or just type in its path (on your system looks like it should be): C:\cygwin64\bin\perl.exe If you always want to open .pl files with perl, check the box to "always open this type of file with this program. then .. OK. If your program doesn't call any other programs, you are done. If it does -- you need to make sure your cygwin paths, especially "C:\cygwin64\bin" are in your PATH var in Windows, at least your User ENV vars... (Control Panel -> System -> System Properties, Advanced tab, @ bottom under Environment vars); Best to try it under user vars first (if you really mess up, you can signing as another user and correct it, but if you mess up the system path, your system may not even boot correctly, if at all). Either append or prepend your cygwin64 bin path to it and use ";" (semi-colon) as a separator (no spaces). Personal hint - When I have lots of stuff in a path, I find it easier to go into the edit box, use Control-A (select all), and ontrol-C to copy the text and open a text editor (gvim). There I use the command (: is the colon prompt in vi) :s/;/^M/g to get ^M -- press control-V, control-M... That will put each path on a separate line. When I'm done, I do the opposite: (% means 'all lines') :%s/\n/;/ Sometimes you need to delete an extra ';' off the end...after you do the above because vim will often insert an extra 'end of line' at the end of the file. I.e. the end of the path should probably not end with a ';', but it probably won't hurt if it is there (I'd have to test to see). --- Except for the PATH part, the "opening" part is done in explorer... Once you have cygwin in your PATH, you can add other programs the same way like mapping ".sh" -> C:\cygwin64\bin\bash.exe" .sh -> C:\cygwin64\bin\bash for example. -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-03-20 2:33 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2014-03-09 19:22 Executing a perl script from Windows 7 Peter Holsberg 2014-03-09 20:16 ` Max Polk 2014-03-09 21:50 ` Peter Holsberg 2014-03-10 2:25 ` Andrey Repin 2014-03-16 0:00 ` Reini Urban 2014-03-20 15:02 ` Linda Walsh
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).