Re: running a script from Windows Desktop
by TomDLux (Vicar) on Mar 08, 2004 at 21:23 UTC
|
| [reply] |
|
I have Windows XP and I tried doing that. But it opens up in Notepad (the shortcut does) instead of executes in the command window as my script needs to. I have ActivePerl installed. How can I make a perl file execute in CMD?
| [reply] |
|
I guess you have to call the perl interpreter (with absolute path) and your script as parameter.
So do I in my Icons under Win2k.
HTH
| [reply] |
Re: running a script from Windows Desktop
by arden (Curate) on Mar 08, 2004 at 21:23 UTC
|
Assuming you mean for Win32, yes, you can create a shortcut by right-clicking on the desktop and selecting New->Shortcut and filling out the wizard. You can either call the script.pl directly with or without arguments or you can call perl with your script.pl as the first argument.
Of course, if perl.exe is in their path and configured correctly (utilizing the .pl extension), they can just double-click on the script itself.
- - arden. | [reply] |
Re: running a script from Windows Desktop
by Juerd (Abbot) on Mar 08, 2004 at 21:27 UTC
|
Hi Monks , this might sounds like a stupid question but Is it possible to create an icon on your disktop which will call your perl script . I am writting a small script for a user who dosn't know what is command line mean . so I want him to click on the icon instead of the command line call. thanks .
That depends on the kind of desktop that they use. Windows, KDE, Gnome and Mac OS all have different kinds of icon shortcut solutions.
You could of course just associate .pl to be run by perl or create a real executable using PAR.
| [reply] |
Re: running a script from Windows Desktop
by AcidHawk (Vicar) on Mar 09, 2004 at 06:03 UTC
|
By creating a shortcut using "C:\perl\bin\perl.exe c:\somedir\yourscript.pl" you are effectively assuming that the user has perl on their desktop. If they do not know what a command line is why should they have perl installed..? (Unless of course you have installed it.) Another way would be to compile the perl source using something like Perl2exe and just copy the .exe and .dll to the users machine after which creating a shortcut would be as simple as drag and drop.
-----
Of all the things I've lost in my life, its my mind I miss the most.
| [reply] |
Re: running a script from Windows Desktop
by wolfi (Scribe) on Mar 10, 2004 at 07:39 UTC
|
ans: yes - i would dare say, you could run this via shortcut on any win32 system - (i can run it on winXp). What you need...
1) create the shortcut. I simply right-click/send to desktop (create shortcut) or you can use the methods others have stated.
2) ensure that the sys has perl (i use ActivePerl)
3) associate it w/the perl-interpreter. Windows associates programs not by #! lines, but simply by theut extension. If you're rec'ving a notepad/text version, instead of it being executing, it's because the file-extension is associated w/that program (NOTEPAD).
go into CONTROL PANEL -> FOLDER OPTIONS -> FILE TYPES and look for the extension .pl or .cgi (etc). Delete it.
go back and double-click on it - you should rec'v the "OPEN WITH...?" prompt. From there browse thru your folders until you find your perl.exe ("perl command line interpreter") and select that. Next time it runs, it should execute the perl script via that.
The ugly black box may quickly pop real brief - but whatever the results of the script (add file / delete file... etc) will be executed -> without your friend worrying about typing commands.
| [reply] |
Re: running a script from Windows Desktop
by Corion (Patriarch) on Mar 10, 2004 at 07:46 UTC
|
As an additional idea, ActiveState Perl comes with a nifty utility pl2bat, which wraps almost any Perl script in a .bat or .cmd file, which then can easily be sent somewhere as a shortcut.
Personally, I don't use pl2bat much, I use the following template to start my Perl scripts in their "home directory", but this template only works on NT upwards:
cd %~dp0
perl -w scriptname.pl "%1" "%2" "%3" "%4" "%5" "%6" "%7" "%8" "%9"
That batch file must reside in the same directory as the .pl file. There is another utility that is even more general than my template, but I don't know the name. It is somewhere included in either ActiveState Perl or on the CPAN, and it is a batch file that starts the Perl script of the same name, so you'd copy it to somescript.cmd and it would try to start perl -w somescript.pl - that could be very useful as well. | [reply] [d/l] |
Re: running a script from Windows Desktop
by fraktalisman (Hermit) on Mar 10, 2004 at 23:24 UTC
|
and you can also use drag and drop in MS Windows. If you add %1 to the shortcut, the filename of a file dropped on the shortcut is handled to the script. To handle more parameters from other programs, %1 %2 %3 etc.
So users won't even have to type.
You say the person who will use it doesn't know what a command line is. This kind of people usually don't have perl installed, so you'd have to install for them. If you install anyway, it's also possible to install a web server and provide a "web" environment with the perl scripts. That would be something most computer users are quite familiar with, and using the script would be "just like surfing". | [reply] |
Re: running a script from Windows Desktop
by pbeckingham (Parson) on Mar 08, 2004 at 22:45 UTC
|
I think these days the answer to this question is a ubiquitous 'Yes', regardless of your (unspecified) desktop environment. Furthermore, the mechanisms for this are all desktop-specific, and are not Perl-related.
Now if you were asking about running scripts from the various command line interpreters out there, you would not be able to avoid typing in the file extension for Windows, as it doesn't completely obey the shebang. | [reply] |
Re: running a script from Windows Desktop
by ambrus (Abbot) on Mar 09, 2004 at 16:24 UTC
|
If all the other suggestions fail,
just create a batch file that starts perl
with the script name as the argument.
| [reply] |
A reply falls below the community's threshold of quality. You may see it by logging in. |