How can I easily host a CGI executable (.exe) file locally on windows - windows

I have been able to make Common Gateway Interface (CGI) executables work in IIS / IIS express in the past, but its a real faff and always takes a lot of trawling through the internet and trying lots of things, and it seems to change a bit in each version of IIS.
Is there an easier way?

If you have Python installed, you can run this from the command line:
python -m http.server --cgi 8000
You will need to run it in the directory that the website is in, and the CGI executable should be in a cgi-bin sub directory. More details on the Python Website
If you haven't got Python installed, it is probably easier to install it, than it is to get IIS working.

Related

ruby - copy a jar from linux to windows server

We are having a linux build server and the build scripts are written in ruby. All the jars are deployed on linux servers only and are generally copied to the application servers using ssh.
There is a new service which needs to be deployed on a windows server. Is there a way to copy and configure the jar deployment from the linux machine to the windows server.
Using ruby / shell scripting?
If you are already using SSH in your build script I would think the easiest thing to do would be to install an SSH server on the Windows box. You can use sshd via Cygwin or opt for a commercial product like WinSSHD (I'm sure there are numerous other free or paid products out there).
Once you have that running you can more than likely reuse most of the existing script relating to moving files around and use a gem like Win32Utils to do any windows specific tasks.

Symfony2 and Assetics : symlink on Windows 7?

I'm having a hard time using assetics to load resources in my views (I work with Symfony2).
I was working on Linux (Ubuntu 10.4) and switched to Windows 7 a few days ago. I've always been having trouble (some images didn't load for example), but at least most images, and all styles and scripts were loading alright.
When I switched to Windows, some resources weren't loading, so I tried a php app/console assets:install web --symlink
I was quite surprised to see that it had deleted the whole public folder of the bundle I was working on. And there was no way to find the sources again (fortunately, I had saved some of them, and I was able to retrieve most of my work thanks to cached files).
After I've recovered my files (and backed them up), I tried to command again. Same result. I tried without the --symlink and it created some folders in the web/bundle folder, instead of files that were there before (supposedly, the symlinks).
Now the command doesn't even answer anymore (it has been erasing my sources even in some of my backup folders!!).
Bottom-line : is there a way to configure assetics on Windows 7 so that it doesn't eat my files and loads the resources (including images in css) correctly?
Thanks in advance!
Edit :
I just ran the command again and this time it worked (copied the files in web/bundle/...). I must say I don't really understand how or why it worked this time... If by chance anyone knows...
In order to run assets:install web --symlink on a PC you need an elevated command prompt (fancy word for cmd.exe in Administrator mode).
Symfony2 uses the PHP symlink function, according to the docs it should work for Windows Vista, Server 2008 or greater.
By default only Administrators can create symlinks in Windows. So you'll have to use an elevated prompt or give your user the SeCreateSymbolicLinkPrivilege privilege.
You can do it with windows console, but Git Bash is much nicer. Get it and download. Ps. If you never used git before this is the right time to start. :)
When you installed it search in windows programs for git bash and right click it to run as administrator. If you have Git bash opened from the right click in the current folder "git bash here" it wont work because it is not launched by default in administrator mode. If you done this you get this warning.
app/console assets:install web --symlink
Warnings. Hard copy where used instead of symlinks.
However if you play nice and do it as i said. (run as administrator.. you will get everything work nice and smooth.
app/console assets:install web --symlink
Symlinks where created! :) Now you don't need to assets:install every time you made changes to your css files.
Ps. git bash console is nicer then native windows console but... for example Unix system such as Ubuntu would look even better. Also Symfony on Windows with Xamp will run much slower than on Linux Ubuntu system. I am talking about 5x to 20x faster page response on Linux.
You can use configure the composer.json and use forever without any problems,puting in it --symlink.Here is how you can do it.
http://www.w3docs.com/snippets/symfony/how-to-keep-symlinks-in-web-bundles-after-composer-update.html
You can add this configuration option in your composer.json:
{
"extra": {
"symfony-assets-install" : "symlink",
}
}

Node.js - tutorials on getting it to work with Cygwin on a Vista machine

All,
Am trying to get Node.js to work on Vista machine.
I installed Cygwin (as per the Github instructions) which appears to have been installed correctly. However, none of the commands are executing.
Are there any tutorials for the stages after the Cygwin installation?
PROBLEM: When any command is executed, I get 'Bash: command not found' error.
Not even command like 'c:\cygwin\bin' is executing.
When I type 'user' in cygwin command prompt, I get 'ntvdm has encountered an system error. Parameter incorrect'.
I thought the above error may be due to the firewall, disabling the firewall did not have any effect, running the program with admin rights also did not change the results...
Am confused and would love to get some guidance on what steps to go with next on getting Node.js up and running on a Windows Vista machine.
Many thanks,
UPDATE1:
We managed to make a bit more progress. It appears that we had not installed all the relevant files related to Cygwin. Upon re-download and reinstalled, it ran well, however, we have driven into another error. Error we get:
How to compile/install node.js(could not configure a cxx compiler!) (Ubuntu).
We followed the instructions as per the above thread (3rd post from top for Windows machines), however, we are still stuck at the same error.
Any guidance please?
Have you tried just using the Windows self contained binaries? http://node-js.prcn.co.cc/ This way you actually don't need to bother with Cygwin.
At first, i tried it your way too, using Cygwin. After smashing my head for the 10th time against a wall i just stopped trying and found a much cleaner solution.
I'm using VirtualBox running a Debain guest system to locally develop on my Windows 7 machine. Using VirtualBox, you can easily set up shared folders or port forwarding for node apps between your Windows machine and your Debian guest system.
Since you are using a plain Linux-system, all the compiling-pain is blown away.
If you plan to run node.js in production on a windows system: don't. I hardly believe node.js will be ever stable enough on windows-based systems using MINGW/Cygwin...
People seem to run into problems with Cygwin because they think that they are using a Windows machine.
If you install Cygwin, and open a bash shell prompt using the Cygwin icon, you are now in a UNIX environment and everything works the same as it would on UNIX. That includes building node.js.
I think you added some info to the question and I can see your problem. Yes, normally on Cygwin it has been possible to build node.js just as you would on any UNIX system, but that is no longer possible on Windows 7. Before running ./configure you have to:
Close all cygwin apps.
Double-click on C:\Cygwin\bin\ash.exe
Run ./rebaseall and when it completes, run ./perlrebase.
exit from the ash shell window.
At this point Cygwin will be back to normal and you can ./configure and make install.

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.

How can I install package in ActivePerl without Internet connection?

In ActivePerl, "ppm" installs a package from the Internet, "ppm install x.ppd" installs from a ppd file, but most CPAN packages are distributed as .tar.gz
How do you supply modules to a machine running ActivePerl that doesn't have an Internet connection? ("make" will probably not be available.)
Update: an Internet connection can be used to download files and transfer them to the machine with a USB key, etc.
I am sure there is an easier way, but I just checked a ppd file and it is just an xml file ...
So you should be able to do the following if you want to install manually on a pc with no connection:
Open the file , ex
http://trouchelle.com/ppm/Acme-LOLCAT.ppd
and download the appropriate file pointed to in the CODEBASE tag, in this case:
http://trouchelle.com/ppm/MSWin32-x86-multi-thread-5.8/Acme-LOLCAT-0.0.4.zip
Put both file on the pc with no connection, CODEBASE HREF="xxx" should be pointing to the zip file (either by putting the file in the same relative subfolder or by fixing the href so it points to the zip file on your disk)
Install from the ppd using
ppm install x.ppd
See: http://docs.activestate.com/activeperl/5.10/faq/ActivePerl-faq2.html#zip_files
I know it's not an answer to your question, but if possible consider using Strawberry Perl, a CPAN-friendly distribution of Perl for Windows. It has a tidy installer, ships with make, a compiler and a properly configured CPAN shell all ready to go.
And then you can use something like minicpan to create an offline CPAN repository.
Don't be a second class Perl citizen and have to wait for someone else to compile you a ppm, drink straight from the CPAN firehose!
Since this is a very frequent scenario, I complete the answers here :
As far as ActivePerl 5.14 is concerned you can also download ".tar.gz" files for your platform, or download so-called ".ppmx" files (same format). Save the files and invoke the ppm installer later when offline :
ppm.bat install MIME-Lite-3.028.ppmx
You might be interested in A guide to installing modules for Win32. It's a bit outdated (it talks about the command-line ppm) but the principles remain the same.

Resources