Multiple versions of Perl on Windows 7 - windows

This is my first day with Perl. I am confused with multiple versions of Perl on my system (Windows 7 32-bit). After installing DWIM Perl when I checked for a Perl installation using 'perl -v' it was showing
This is perl, v5.8.8 built for msys-64int
and after setting the path of System Variables to the E:\Dwimperl\perl\bin directory it is showing
This is perl 5, version 14, subversion 2 (v5.14.2) built for MSWin32-x86-multi-thread
Does Windows comes with Perl installed? And will overwriting PATH do any harm?

No, Windows doesn't have Perl installed by default. Someone before you has installed Perl 5.8.8
You probably won't do any harm adding a location to the PATH environment variable, but your question isn't clear. Have you changed it to just ...\Dwimperl\perl\bin, or have you added it to the end?
You really shouldn't use relative paths in the PATH list, if that is what you've done. Do you really have three dots in there? If so then I am surprised that it works at all.
I suggest you run appwiz.cpl and look to see what is installed there. Remove the older Perl if you are sure there is no need for it.
Also, I recommend that you use Strawberry Perl rather than the DWIM fork. The only real difference is that it has a lot of additional modules pre-installed that you may well not need, at the expense of being a couple of versions behind basic Strawberry Perl

Related

How install multiple version of perl

I have the following question in perl.
1) Is it possible to install multiple version of perl(example perl version: 5.6 and perl version 5.24) in windows system.
2) In case if the above question 1 is possible then how to call the perl file using version. For example, call the new version perl file from old version of perl file.
On Windows systems
You can use berrybrew
To get a list of available versions:
berrybrew available
Based on available versions you can install with following command:
berrybrew install 5.10.1_32
To switch the version:
berrybrew switch 5.10.1_32
On unixy systems
Using perlbrew, you can install different versions of Perl.
You can run a single command against a specific version of Perl using the following command:
perlbrew exec 5.27.11 myscript.pl
You don't need to do anything special. Strawberry Perl is the de-facto standard version of Perl for Windows, and its installer gives you the option of specifying to which directory you want to install it.
For example, I have
...
C:\progs\sp5280-x64 # Perl 5.28, 64-bit
C:\progs\sp5300-x64 # Perl 5.30, 64-bit
C:\progs\sp5302-x64 # Perl 5.32, 64-bit
Simply specify which Perl you want to use when you launch a program.
C:\progs\sp5302-x64\perl\bin\perl a.pl
By editing your PATH and the file association for .pl files, you can set the default perl used from the console and by double-clicking a .pl file.
I suck at Windows administration, but here goes my stupid suggestion anyway.
1)Install different versions of perl in different folders.
2)Include all folders in the %PATH% variable.
3)Rename the perl executables to its version:
perl.exe (5.4) --> perl5_4.exe
perl.exe (5.6) --> perl5_6.exe
4)When using the console to execute it, use
perl5_4 [file]
My honest recommendations are:
Use VirtualBox or any OS virtualization application, which is heavy in hardware requirements but works like wonders.
For any multi-version environment, always use Docker.
Just use Linux and install perlbrew
Simple Way to Do this use Virtual machine
and insall os in VIRTUAL BOX and Install old/new Version in Virtual machine.
Download Virtual BOx

Perl 5.20.1 version downloaded.How to set up the path?

I downloaded strawberry perl 5.20.1 to my windows 7.
I also installed cpan module.
However when I run the program, it still shows that cannot find NET::OpenSSH
Should I make correct path in environment variables on my computer? If yes, how an what is the correct path?
Should I use something else instead?
I just want to login to Linux box from windows 7
From perldoc Net::OpenSSH,
On the other hand, Net::OpenSSH does not work on Windows, not even under Cygwin.
[..]
Net::OpenSSH does not work on Windows. OpenSSH multiplexing feature requires passing file handles through sockets, something that is not supported by any version of Windows.
As documented in Net::OpenSSH #Known Issues
Known issues
Net::OpenSSH does not work on Windows. OpenSSH multiplexing feature requires passing file handles through sockets, something that is not supported by any version of Windows.
Alternatives
For alternatives, look at:
Net::SSH::Perl as suggested in How to SSH from Perl script from windows machine to EC2 machine.
Net::SSH2 as suggested in Unable to install the perl module Net::SSH::Perl on windows 64 bit.

How do we configure SSH using Perl in Windows?

Can anyone suggest a a very simple way to use Net::SSH::Perl in Windows without all those cygwin hacks and all.
Whenever I am trying to install the modules it's taking me to some other dependent modules and the process seemed never ending..
Thanks beforehand
Here is a post on how to do it I found.
I recently had a project that required a script to perform an SSH session to a Cisco device and make some configuration changes. My favourite scripting language is, of course, perl.
I had previously written scripts using the Net::Telnet module that would Telnet to a device, detect various device prompts and send commands to the device to change its configuration. So, I thought that this was going to be a fairly straightforward case of just finding a suitable, similar module that uses SSH instead of Telnet.
The other thing that I need to mention is that I am generally constrained to using Win32 platforms (i.e. Windows 200, 2003, XP) due to the fact that most client sites that I work on these days do not use Unix(or Linux) ..which is a real pity in my opinion, but I don't set the corporate policies of my clients.
An initial glance of the available perl modules revealed a number of modules which seemed to be just what I needed :
Net::Appliance::Session
Net::SSH::W32Perl
Net::SSH
So, I told my boss, 'Yep, no problem' and set about pulling together a script to SSH in to a remote device and send it some commands to change its configuration.
After a day or so of trying various modules, I thought : 'Hmmm, maybe this isn't going to be as easy as I'd thought!'
Each of the modules I'd looked at seemed to have an issue when it came to using it in a Windows environment. To summarise, here are the issues I found with each module :
* Net::Appliance::Session : has a dependency on IO::Pty, which won't ever run on Windows
* Net::SSH::W32Perl : ``getpwuid function is unimplemented'' message`` when building from scratch. Older ppd's found at http://www.soulcage.net/ppds.58 just don't seem to work....even when installed in to the Activestate perl distribution
* Net::SSH : Unix only
So, at this point, I was beginning to think that maybe this just wasn't going to work at all on Windows....
Then, I remembered seeing a posting on perl mongers where someone has mentioned that they had used perl in cygwin to run one of the Net::* modules.
So, although the thought of having to download and install cygwin didn't initially seem too appealing, I thought I'd give it a go as I had no where else to go.
Cygwin
Cygwin is...well, let me quote directly from the cygwin web site :
``Cygwin is a Linux-like environment for Windows. It consists of two parts:
A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality. A collection of tools which provide Linux look and feel.
The Cygwin DLL currently works with all recent, commercially released x86 32 bit and 64 bit versions of Windows, with the exception of Windows CE.``
So, it allows you to run in a Linux-type environment...sounds far more promising for the various Net::* modules that I had been looking at.
Also, once the basic cygwin core is installed, it allows you to download and install a whole host of other goodies, including perl !
So, I set about installing cygwin by downloading the 'setup.exe' file from the cygwin home page and running it on my PC.
Cygwin provides a failrly intuitive GUI to let you select a mirror to download files from, and which packages you would like to download.
Here are the packages that I installed beyond just the basic core cygwin packages that are installed for you :
gcc-core
gnupg
make
ncftpget
openSSH
perl
perl-ExtUtils
wget
zip
You can install others (in addition) if you like, but these did the job for me.
Perl
Once I had cygwin installed (including the perl distribution that I included), I was all set to add in the modules that I wanted to try to use (e.g. Net::SSH::Appliance).
If you are familiar with perl on Unix systems, then you will probably be very familiar with the CPAN shell to add modules into your perl distribution. Under cygwin, the process is exactly the same.
If you are used to using the Activestate version of perl, you are probably used to using the Activestate PPM manager to add new modules to perl. Well, the bad news is that under cygwin, you don't have a PPM manager, and you have to use the CPAN shell, which is a little bit trickier to use if you aren't used to it. The good news however, is that you will have access to far more perl modules !
When you installed cygwin, it will have put an icon somewhere (either on your desktop, quicklauch bar or start menu) so that you can launch the cygwin shell (it looks something like this :
If you click the shell icon, you will get a nice cygwin shell open up where you can type in various commands. You can think of it as a Unix shell to all intents and purposes.
To load in the perl modules you'll need, you need to enter 'cpan' at the command prompt. This will allow you to load new modules in to your perl distribution.
Now, the first time you go in to the CPAN shell, it will aks you lots of rather awkward questions about where various utilities are and which mirror you would like to use. In the main, if you have installed the modules that I recommended for cygwin, you can accept the defaults. (The mirror you will have to figure out for yourself - it depends where in the world you are).
The only setting I would recommend you change from the default is the question about whether you should be 'asked or follow' for pre-requisite modules - I would go for 'follow' to save a lot of hassle.
Once you have your cpan shell open (you can tell, because you now have a 'cpan>' prompt), you need to enter the following commands to load in some perl modules that you will need :
install LWP (accept all defaults to any questions asked)
install Net::Appliance::Session
When you enter these commands, you will see lots of things flying up the screen as the modules are installed for you.
Running Scripts
Well, at this point, we have taken a rather whirlwind tour through getting cygwin and perl instaled on your platform, but you should now be in a position to run some perl scripts.
We installed the Net::Appliance::Session module in to your perl distribution, so that we can run perl scripts that will use it to give us either Telnet or SSH sessions to a target device.
As we are running under the cygwin environment, we can now use this module on a Windows platform - something we couldn't do by just installing Activestate perl, or even by compiling our own version of perl under Windows. So, now, we CAN run perl scripts that will allow us to perform SSH sessions to network devices that only support SSH.
You may be wondering : ``does that mean that I have to run my perl scripts from the cygwin shell every time I need to run them ?''. Well, the good news is that no, you don't..! As long as you call the cygwin perl executable to run your script, it will run fine from a DOS prompt (or system scheduler !). So, this would work fine :
c:\ c:\cygwin\bin\perl.exe myscript.pl
Anyhow, I guess that's enough to let you know how I cracked my particular issue. I hope to cover all of this in a little more detail in future aritcles, as well as providing more informatipon about how to use the incredibly useful Net::Appliance::Session module to create some useful scripts to control and configure your network devices.
http://perlwin32ssh.blogspot.com/2007/07/test_4418.html
For ActiveState Perl, probably you can try for Net::SSH2 module. I tried with couple of online examples and it worked for me.
You can go through following resources to install and run a sample example using Net::SSH2.
Use this repository to install Net::SSH2
http://theoryx5.uwinnipeg.ca/ppms/
couple of examples:
http://www.perlmonks.org/?node_id=569657
Hope this will work for you. I tried it and it worked for me.
The answer about using Perl from within Cygwin then calling it from the Windows command line is the correct answer. THANKS VERY MUCH FOR YOUR EFFORT!
However, this method to call a PERL instance running in Cygwin from the Windows Command Line is not always optimum:
c:\cygwin\bin\perl.exe myscript.pl
That technique will work with some Perl scripts but not all. It was giving me heck trying to use NET:SSH:EXPECT and the login() method. It would abort with strange errors.
A better way to call your Perl instance running in Cygwin from the Windows command prompt is this:
c:\cygwin\bin\bash --login -c 'perl myscript.pl'
This seems to execute the Perl script fully within the Cygwin environment and even complicated Perl scripts or those with many dependencies or not capable of dealing with MSDOS style path names, will still run. You can still return the output of the Perl script back to the Windows command window, for instance using print() from within your Perl script.

Portable unix-like environment for Windows

I am trying to put together a portable set of files/scripts that will enable me to mimic a unix like environment on Windows.
I do not want to install anything. The setup needs to be able to live on a thumbdrive for example. Currently I am using UnxUtils to provide grep, and more. Im adding these to the Windows PATH environment variable in the current console session by
cd <pathToUnxUtils>
path = %PATH%;%CD%
For Vim (my preferred editor) I am using the "Win32 console executable" (http://www.vim.org/download.php#pc) vim.exe. If I have that in a drive such as \vim\vim73\vim.exe then $VIMRUNTIME is \vim\vim73, which is where my vimrc lives.
I am trying to get some syntax highlighting and indenting going next, which I believe I need to add the appropriate .vim scripts to $VIMRUNTIME\syntax and $VIMRUNTIME\indent
but it does not seem to work.
I am using the console executible instead of something like gVim (which probably does more of what I want "out-of-the-box") because I want to be able to send commands to the same shell using the ! command. gVim does not allow that (correct me if I am wrong)
Lastly, has anyone experienced trouble with "tail" from UnxUtils working on Vista?
I know this probably seems like a stupid way to go about things, but I am really trying to make this work. Id be happy with getting these bits of Unix goodness going on Windows.
Thanks for any help
Check out cygwin portable: http://symbiosoft.net/cygwinportable
Or this guide on how to make regular cygwin run on portable devices: http://sites.google.com/site/devinsezer/Home/software/portable-cygwin
The advantage of cygwin over a thin emulation layer like UnxUtils is that it includes a fully working X11 server so you can even run GUI unix apps if you need to (gitk for example, if you're using git)
I've had some troubles with UnxUtils before re currency - they don't seem to be as up to date as the GnuWin32 stuff (for example, TextUtils at 2.1 instead of 5.3).
I've simply downloaded the executables and required libraries for what I've needed (no install needed if you avoid the setup packages, just copy and go).
If you click on the package names on the left of that second link above (not the "Setup" on the right), it allows you to download both the executable plus all dependencies on a single page.
My particular needs for a recent project were met with sed and about four DLL files, no installation, no impinging on the environment or registry. In short, ideal for running from a memory stick or standalone CD.
I must, at some point, put together a CD with the entire suite on it. I used to carry around CygWin but the necessity to install was a pain.
I'm using MobaXterm from Mobatek.
http://mobaxterm.mobatek.net/
It's not a complete envoirement, but is quite suficcient.
Just download and run!
It have an (ba)sh, with X, sed, grep, awk, rsync, wget, sftp, scp; and some extra plugins (standalone files to put in the same dir) to VIM, EMACS, perl python, Gcc, gdb, mplayer, svn, git, lua graphviz...
It still provides many protocols (RDP, VNC, SSH, telnet, rsh, FTP, SFTP and XDMCP).
Either MSYS or CH will do that, there is a specifically portable VIM at portable apps
Cygwin and MSYS provides all you need. I have used both and I think MSYS runs faster than Cygwin on a Windows machine. Cygwin emulates the UNIX environment whereas MSYS is port of the GNU utils to Windows.
Another option to get portable GNU utils is to install Portable MsysGit.
http://www.cygwin.com/ is very popular.
update: oh, never mind - I don't think it can be xcopy deployed.
-Oisin
I've had good luck with running Cygwin on a thumbdrive. I haven't run it on machines where older versions are installed. But I don't expect to have that problem often.
Here is what I did: http://fadedbluesky.com/2011/portable-cygwin/

Unix-style tools on Windows?

At work (a mostly Unix development shop), I've had an OS X box for the past 1.5 years and a Linux box before that. Due to various circumstances, I'll be getting a Windows XP laptop in the next few weeks. I'm of mixed feelings about this - it's good in that, as a manager, I'm used to running a Windows install (via Parallels) for Excel, Outlook, etc., but it's bad in that I'll miss all of the Unix tools available on OS X.
So, my question to you (community wiki perhaps?) is: What sort of tools would a Unix developer find handy when using a Windows machine? I'd like to be able to do some development on the machine (Perl, mostly), and also easily remote to other (Unix) machines. Here's what I've been recommended so far:
Editor: gvim
SSH: PuTTY
You want cygwin -- and secondarily, for when you absolutely have to work in a CMD.EXE console, unxutils.
Try MinGW, the Minimalist GNU for Windows. Here's a list of GNU tools they offer: http://sourceforge.net/projects/mingw/files/
This includes things like bash, sed, awk, grep, cut, and other familiar GNU tools. Perl is in there as well. I find it a good light-weight alternative to Cygwin.
On windows, you will miss the great GNU/Linux/Unix tools like sed, awk, wget, grep, tr, locate, file, dd, diff,
I wouldn't recommend cygwin though, I prefer native tools.
You can find native ports of the GNU tools at
http://gnuwin32.sourceforge.net/
Then you need a decent syntax highlighter, notepad is just an antique.
Geany is best on Linux, and there is a windows port:
http://www.geany.org/Download/Releases
There is also a windows port of The Gimp, free and opensource, offers the same and more functions as adobe photoshop (but with another interface). It's modest bit more difficult to use, though.
http://gimp-win.sourceforge.net/
For a C/C++/Lisp/Ada compiler and makefiles, you need MinGW, Minimalist GNU for Windows, together with msys (a linux like console).
Unlike cygwin, mingw and msys compile native win applications.
Windows doesn't have Perl installed by default.
You can download a free Perl interpreter from http://www.activestate.com/
Finally, you could install CoLinux, with which you can run Linux apps. on Windows.
CoLinux is hard to install, AFAIK, and you can mess up your computer if you don't know what you do.
If you have Vista Ultimate or XP, you can install SUA/WSU, Windows Services for Unix.
On Vista, it's in the OS Components tab under add/remove software in the control panel
On XP, you must download 300 MB from Microsoft.
Cygwin
Linux-like environment for Windows
making it possible to port software
running on POSIX systems (such as
Linux, BSD, and Unix systems) to
Windows.
Is your laptop good enough to run a VM? That will certainly get you the best of both worlds.
Instead of Cygwin or putty consider MobaXterm and maybe a few plug-ins.
No install needed and it is free; based on Cygwin code.
You just start a single executable file.
It includes the Busybox implementation of vi, sed, awk, wget, and grep, as well as openssh-server, ssh, scp, bash, rsync, X server, {lots more} and you can add things like perl, emacs (why?! :D ) screen, curl or python as plug-ins just by downloading them (versions from the mobaxterm site) into the same directory.
The tools in Busybox are not POSIX complete, but it is a pretty good start out-of-the-box.
It only takes a few minutes to be up & running.
Be sure to set up a persistent home directory and restart mobaxterm so you can keep your ssh keys, bash profile, etc. (ssh-keygen is included...)
You do not need to license it but you get a few extra goodies if you do.
The first thing I do on windows box is to download mobaxterm. I do not use putty anymore unless I have no choice.
main site: http://mobaxterm.mobatek.net/
some plugins: http://mobaxterm.mobatek.net/plugins.html
Just download the 'portable edition' zip file, extract it into a directory, open the executable {NOT the customizer...}, ignore any warnings, set a persistent home [Settings > Configuration > Misc Tab], close the application, restart the application, and then configure to your taste. This way all of your settings will be saved.
Now you can also make another directory to save logs to and turn on logging.
I like leaving 'Paste using right-click' "OFF" (unchecked) because it automatically pastes with a middle-button click anyway, like many terminals. BTW: Highlighting text adds it to your buffer/clipboard automatically.
TIP: try "cd /drives/c/foo/bar" or the like and then search & parse your windows log files with grep, sed & awk ...
DISCLAIMER: I do not work for mobatek or develop mobaxterm but I am a licensed user.
Cygwin gives you Unix command-line tools in a Windows environment.
If the cygwin installation is too heavy-weight for you, and the GnuWin32 installation is too cumbersome (you have to install every tool individually), you can also try out GOW: https://github.com/bmatzelle/gow. The only downside is that the binaries are quite old..
I know I'm late to the party here, however, another great option is Git Bash.
Well, best thing for me is Mobaxterm http://mobaxterm.mobatek.net/features.html
This Cygwin distribution has no installation at all as is one single binary only.
IMHO cmder is better in windows than cygwin to work with unix commands.
Better yet, when you install cygwin select the packages openssh, perl and emacs. Then install ssh daemon using ssh-host-config -y and follow instructions. Now you can ssh to your Windows machine from your Linux box, happily use vi or emacs and develop in Perl, run your perl code, or any other command line Windows exe, or Java or Python, etc. as long as they are console apps (vs a graphical one).
GO for Cygwin.
First install the Cygwin, which gives you a nice unix like terminal. You have lots of additional packages you can install online.
For stuffs like perl and python go for Activestate "http://www.activestate.com/activeperl"
http://www.activestate.com/activepython.
There is also "http://strawberryperl.com/" free, even for commercial usage.
It depends on what you wants:
Cygwin and it’s fork Mingw add Compatibility layer dlls on top of Win32, while SUA/INTERIX run on top of the NT with it’s own subsystem and PE type of executables beneficing many of the things traditionally implemented as *nix syscalls (like fork()) which are available in Native NT but not on WIN32.
So application have a some kind of better support, you can see it here.
Otherwise cygwin is fully supported by red hat which means a lot of binary packages are available while on SUA, the first thing you’ll probably need is to find a way to compile a recent toolchain with the outdated installed one.
I use the Git for Windows "contribute" version, aka msysgit: https://msysgit.github.io/#contribute
This single install includes: MSYS, MinGW, bash, GNU toolkit, gcc, g++, flex, bison, vim, gvim, ssh, git, svn, cvs, perl, tcl/tk, rxvt, etc. It's everything you would need to hack on git, and a good foundation for hacking on anything else.
msysgit takes up 1GB on the disk. (Windows Explorer will tell you it's 3GB, because it doesn't understand hard links.) It builds git from source, and there are a few large git repos.
MSYS+MinGW is lighter than Cygwin. It's better for porting, development, and for general use. It works both in the windows CMD prompt and in an rxvt terminal.
There is also MSYS2, I haven't tried it yet but I hear it is more up to date than msys or msysgit. See also: How are msys, msys2, and msysgit related to each other?
You can also try 'Install Windows Subsystem for Linux' in Win10. Link

Resources