Develop on windows and deploy on linux?

Experts!
This may be a very simple question but i don't know the answer :)

I used to develop my websites on windows and deploy one linux box.

now i need to do the following,
1) I have a script that runs like http://site.com/Login, this has to work on my windows 2003 server, and i will then upload it to the linux box, please note the first line needs to be different for windows and linux right?

2) I really need to work on windows and deploy on linux,

possible? if so how?

Dev environment: Windows 2003 server, apache 2
production server : Linux, apache 2
LVL 12
str_kaniAsked:
Who is Participating?
 
FishMongerConnect With a Mentor Commented:
Windows neeeds the script to have an extension in order to determine which application it needs to associate.  What happens when you add the .pl or .cgi extension?  What is the exact error message in the error.log file?
0
 
mjcoyneCommented:
I write CGI scripts on Windows and deploy them on Linux all the time.  I always use #!/usr/bin/perl -w as my she-bang line; Windows doesn't care what's here.  I'm not entirely sure what your question is -- if you're just asking if you can script on Windows and deploy on Linux, the answer is yes.  There will (obviously) be some differences in pathnames and such (for example if you write to a log file or something), but these are easy changes to make after testing, especially if you put things in variables near the top of the file...
0
 
str_kaniAuthor Commented:
that's really good news, do you say the cgi script work regardless of the top line (on windows)
i had to  to change the top line as the following to make my sample script work...

#!d:\perl\bin\perl.exe
    # ^^^ this must be the first line of the script! ^^^
    # start code
   
    use strict;
    use CGI;
    my $q = new CGI;
   
    # print header and start the markup output
   
    print $q->header( "text/html" ),$q->start_html( "hello from perl cgi!" );
    print $q->h2("hello dave...");
    print $q->end_html;
    # end code


0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
FishMongerCommented:
Windows doen't care about the shebang line bucause it uses the file extention to associate it with the program that it needs to run the script, in this case perl.  However, if you're witing cgi scripts and using apache as your web server, then the shebang line does matter to apache.
0
 
GnarOlakConnect With a Mentor Commented:
I run into trouble when I have installed perl packages on my windows machine that don't exist on the deployment box.  I have tried to get in the habit of running a simple perl script that just has the 'use ...' statements on the target box so I know if there will be a problem.  For example, my current project uses XML::Simple which doesn't exist on the target machine so I had to install it locally; I don't have access to public library directories.  That package will have to become part of the deployment or I'll have to get our sysops to install it.

FishMonger is dead on about the #! at the top.  It's unecessary on windows and I've often forgotten it entiryly and then tried to run a script on a linux/Unix box and it doesn't work.  Again, I try to get in the habit of adding it first for whatever the target box is.  Fortunetly my company likes to put things in different places on different families of machines so it's a challenge sometimes to keep one's sanity when moving files around
0
 
str_kaniAuthor Commented:
Not clear at the moment!

Is that possible developing in windows and deploying on the linux servers...
0
 
FishMongerCommented:
The short answer is YES, you can develop the script in Windows and deploy it on Linux.

The key thing to remember is, when ever possible, avoid code that is OS specific.  As you already know, the first line of the script, known as the shebang line, needs to have the correct path to perl which not only differs between Windows and Linux, but also varies between different Linux installations.  Some systems use /usr/bin/perl which is probably the most common, but some use /usr/local/bin/perl and there are a couple other common paths.

To maintain portability, avoid using the system call or backticks to run external commands.  Instead, use Perl methods (modules) that are designed to be portable.
0
 
mjcoyneCommented:
What about my answer has left you unclear?

"I write CGI scripts on Windows and deploy them on Linux all the time...if you're just asking if you can script on Windows and deploy on Linux, the answer is yes".

Kind of unambiguous, I thought...
0
 
str_kaniAuthor Commented:
>>>> write CGI scripts on Windows and deploy them on Linux all the time.  I always use #!/usr/bin/perl -w as my she-bang line; Windows doesn't care what's here.  I'm not entirely sure what your question is -- if you're just asking if you can script on Windows and deploy on Linux, the answer is yes.  There will (obviously) be some differences in pathnames and such (for example if you write to a log file or something), but these are easy changes to make after testing, especially if you put things in variables near the top of the file...

It took some time, but now i understand you point.
Yes i do use some logging in my scripting... but i have a common file to specify the path so i can change it if needed....

>>>Windows doen't care about the shebang line bucause it uses the file extention to associate it with the program that it needs to run the script, in this case perl.  However, if you're witing cgi scripts and using apache as your web server, then the shebang line does matter to apache.
Yes, I use windows and apache, does this sound possible for you?!
0
 
mjcoyneConnect With a Mentor Commented:
Judging from the pointer to this question, you're looking for further information, str_kani -- but I'm not sure what additional data you seek.

Development of CGI scripts on Windows machines using ActiveState Perl and testing them under Windows Apache with an ultimate goal of deployment to a Linux or Unix server running the *nix version of Apache is not only possible, but it's done all the time.

Is there a particular problem you've run into that we can help you with?
0
 
FishMongerCommented:
I see that you've posted pointer question to revive this thread.

Each of us has answered your question and told you that we "write CGI scripts on Windows and deploy them on Linux all the time", so I'm not sure what else we can add.  Have you done any testing?

Is it possible that your question is lacking some details that would help us to better understand what you're doing and what you need to accomplish?  Can you rephrase your question and provide more details?  Can you post a script that you're developing?
0
 
str_kaniAuthor Commented:
So far, i have understood that this is possible. in my case,

1) I have a cgi script web application (which does not have a extension for some reason) you can see that if you see my question. Login.pl or Login.cgi is not there but Login

so i need to login using http://site.com/Login

2) My development environment:  Windows 2003, Apache 2 [installed active perl also]

I copied all my scripts from linux machine to my windows server and the Apache doesn't understand and process this file... and throws "Internal server error"

3) I was using IIS, I had to change this to Apache as IIS not able to understand anything with extentions (example Login instead of Login.pl)

I think i have provided all, does this give you some additional information. If not please let me know.
0
 
mjcoyneCommented:
Not only that, but depending on how you "copied all my scripts from linux machine to my windows server", the files may have the wrong line endings.  What does Apache's log say on the Windows machine?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.