How to run perl or shell scripts in windows in secured environment without strawberry perl or Cygwin - perl

I need to write perl or shell scripts in windows environment for automation. Please suggest some freeware.
For perl I tried padre perl but post installation it requires connection with CPAN which my proxy doesn't allows.Hence its unable to identify modules once I run perl scripts.
Also for running Shell scripts I tried cygwin but its unable to identify loop statements while running shell scripts.
How should I go ahead?
Thanks in advance!

Why you don't use Activestate? I think is the best perl packaged system for Windows.
Here's the link for the free community edition:
http://www.activestate.com/activeperl/downloads
As for editors, you can also use Komod Edit: http://komodoide.com/komodo-edit/

Related

How can I automate a Perl installation / script

I'm brand new to Perl. We have a useful script in the office that people would like to use. Unfortunately it has been deemed hard to setup because one has to download and install Strawberry Perl, manually install a few CPAN modules from the command line, and then run the script with the right arguments. It's really not that bad and there is a readme to follow but is there an easier way to handle the installation? I'm sure I could make a batch file to install the CPAN modules, but what about setting up the environment variables (if needed)? I don't suppose there is a way to automate the Strawberry Perl installation or have it 'come with' the necessary modules?
How would you normally install software on client workstations? That's the method you should use now.
If you don't have anything like that, I would suggest using psexec http://technet.microsoft.com/en-gb/sysinternals/bb897553.aspx
You should be able to 'silent install' Strawberry Perl with the MSI installer.
http://msdn.microsoft.com/en-us/library/aa372024%28v=vs.85%29.aspx
Then use psexec again, to do the CPAN installs.
If you need to do environment variables, then you can either do that within your perl script, or you might have to mess with the Windows registry remotely.
Create a BAT or CMD script that runs the Perl installer, followed by the CPAN install commands. The trick is probably that when the BAT starts, the Perl install area (C:\Perl\bin or whatever) won't be on the search PATH. That will make it hard to run the CPAN commands. So, the BAT script should include a command to manually add the path to CPAN into the script's environment. You can even build up a list of modules, and run them in a loop. I use ActiveState, not Strawberry Perl, but my installer looks like:
#echo off
Set RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
REG.exe Query %RegQry% > "%TEMP%\checkOS.txt"
Find /i "x86" < "%TEMP%\CheckOS.txt"
If %ERRORLEVEL% == 0 (
echo This is 32-bit operating system...
\\Server\Shares\Installers\ActivePerl-5.16.3.1603-MSWin32-x86-296746.msi
) ELSE (
echo This is 64-bit operating system...
\\Server\Shares\Installers\ActivePerl-5.16.3.1603-MSWin32-x64-296746.msi
)
REM Even though the above stuff should have installed Perl locally and updated the PATH,
REM the new PATH won't be available in this BAT script since it was launched before the change.
REM Add both possible locations for local Perl to the PATH before running the PPM commands below.
PATH=C:\Perl64\bin;C:\Perl\bin;%PATH%
set MODULE_LIST=(Archive-Extract DBI DBD-ODBC Data-Validate Date-Manip Date-Simple File-Copy-Recursive List-MoreUtils Mail-Sender Mail-Sendmail Params-Validate SOAP-Lite Spreadsheet-WriteExcel Text-CSV Tie-IxHash)
for %%i in %MODULE_LIST% do cmd/c ppm install %%i
Your final line would be a cpan command install of ppm, but hopefully you get the idea!

Perl for Windows for Eclipse syntax checking that contains EXPECT and SWITCH?

We are running a CentOS Linux server, on which Perl 5.8.8 is installed. We cannot update Perl on this system.
I am installing Eclipse with EPIC to do some Perl coding onto my Windows 7 workstation. This requires that I install Perl on the workstation as well. I've installed a few different versions of Perl and they all have issues for us... Our code makes use of the Switch and Expect commands.
Strawberry Perl 5.8.8.4 has Switch.pm, but not Expect.pm.
DWIM Perl 5.14.2.1 does has Switch.pm, but can't locate it. It also doesn't have Expect.pm.
ActivePerl 5.16.3.1604 has Switch.pm, but can't locate it. It also doesn't have Expect.pm.
Can someone recommend a Perl that I can install on my workstation that will provide these modules? Alternately, is there a way to install these modules?
Try this with strawberry perl:
perl -MCPAN -e 'install Expect'
This is somewhat answered by Expect - Can I use this module with ActivePerl on Windows?
Up to now, the answer was 'No', but this has changed.
You still cannot use ActivePerl, but if you use the Cygwin environment (http://sources.redhat.com), which brings its own perl, and have the latest IO::Tty (v0.05 or later) installed, it should work (feedback appreciated).

Perl Packer not operating as expected

I've recently installed the Perl Packer module to compile my perl scripts into exe packages. I'm running strawberry perl setup on a windows 32-bit machine. When I attempt to run the pp -o command, I get an error stating that Perl is not part of my path. It is, for some reason, looking for perl in F:/Programs/Strawberry Perl/site/bin/perl.exe, when the true path is F:/Programs/Strawberry Perl/bin/perl.exe. Perl itself runs fine from commandline. How can I get Perl Packer to find my perl.exe?
What about calling this way?
perl pp {your options goes here}
regards

Is it possible with Padre to run and debug Perl scripts with a different Perl version?

Padre is a (open) IDE for Perl that does look promising.
Since Padre is written in Perl itself, it is not apparent whether it's easily possible and practicable to run and debug Perl scripts in this IDE that are running on a different Perl version than the IDE itself.
As an example, say I download the current installer (for Windows) which will install and run Padre on Strawberry Perl 5.12 -- can I then use this IDE to run+debug my scripts that are running on ActiveState Perl 5.8.9? (Yes, and I want them to run exactly on AS+5.8.9 because this is where they'll run in production.)
I am aware that there is a Padre package for AS+5.8.9 but I would much rather install the default IDE package and have the IDE run on the Perl it normally runs on and have my scripts run on the Perl they normally run on.
Insights?
Under Tools->Preferences->Language - Perl 5 you can specify the perl binary as well as its parameters to run your projects.

How can I run a Perl script with ActivePerl?

I just recently installed ActivePerl 5.12.2.1202 on my Windows XP in C:/Perl. I am new to Perl scripting.
I just want to run a Perl program which contains one print statement, which I saved in Notepad with the name ex.pl.
How can I run this Perl program?
Can I use an editor for typing a Perl script other than Notepad?
How do I use ActivePerl?
Run Perl program from command prompt
start->run>cmd (command prompt will appear), write perl full_path_of_your_script,
like
C:\> perl hello.pl #This assumes that perl is in your PATH environment variable.
There are many Perl Editors, you can
used for Perl scripts like DzSoft,
Perl Expess, Komodo Edit etc and also see http://www.perlmonks.org/?node_id=169668 and Perlfaq3- Windows Perl Editors for more detail.
Have a look at http://docs.activestate.com/activeperl/5.12/, for ActivePerl 5.12 documentation.
Perl programs (or any other program run by an interpreter) is run by passing the script as a command-line argument to the interpreter. For example, in this case:
perl.exe ex.pl
Padre the Perl IDE and Kephra are good editors for Perl.
As an alternative to ActivePerl, there is Strawberry Perl.
Perl programs are run using the Perl interpreter, perl.exe.
This is normally done from the command line:
C:\>C:\Perl\bin\perl ex.pl
If perl.exe is in your PATH environment variable that can be shortened to:
C:\>perl ex.pl
If you opted to have *.pl files associated with Perl during installation, you can also double-click on them from Windows Explorer.
If you have *.pl files associated with Perl and add .PL to your PATHEXT environment variable you can run them like any other executable:
C:\>ex
Perl programs are just text files. They can be edited with any text editor (Padre, Kokomo, vim, emacs, Notepad++, etc.). Use whichever one you like best.
ActivePerl is just a distribution of Perl. "Using" it usually means running perl.exe to execute your program. ActivePerl also includes the PPM (Perl Package Manager) utility to make it easier to install modules from CPAN, particularly if you don't have a C compiler available. Most experienced Perl developers prefer to use the cpan shell.
Just to add to the other answers, I use EPIC, the Perl eclipse plugin. I'm using Perl on a Windows 7 64 bit machine.
I still run scripts off the command line in windows using ActivePerl, but for development I like being able to dynamically step through the script line by line.
just to not paraphrase other answers and to be more helpful (even if the post is somehow old ) i recommend using the switch "-e" to run Perl scripts if they are composed of few statements e.g
Perl -e "print('hello')"
and of course this requires that the Perl executable is in the Path variable,if not and assuming Perl is under the folder c:\Perl , you can add it by taping :
set %PATH%=%PATH%;c:\Perl\bin
when it comes to the choice of text editor ,I'm still using Notepad++ for almost everything ,it come with some useful features like keywords highlighting and some auto-completion capabilities.