Solved

Develop on windows and deploy on linux?

Posted on 2006-07-04
13
404 Views
Last Modified: 2010-03-05
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
0
Comment
Question by:str_kani
  • 4
  • 4
  • 4
  • +1
13 Comments
 
LVL 17

Expert Comment

by:mjcoyne
ID: 17039237
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
 
LVL 12

Author Comment

by:str_kani
ID: 17040078
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
 
LVL 28

Expert Comment

by:FishMonger
ID: 17040333
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
 
LVL 6

Assisted Solution

by:GnarOlak
GnarOlak earned 150 total points
ID: 17053642
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
 
LVL 12

Author Comment

by:str_kani
ID: 17126575
Not clear at the moment!

Is that possible developing in windows and deploying on the linux servers...
0
 
LVL 28

Expert Comment

by:FishMonger
ID: 17127370
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 17

Expert Comment

by:mjcoyne
ID: 17128914
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
 
LVL 12

Author Comment

by:str_kani
ID: 17202635
>>>> 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
 
LVL 17

Assisted Solution

by:mjcoyne
mjcoyne earned 150 total points
ID: 17359443
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
 
LVL 28

Expert Comment

by:FishMonger
ID: 17359521
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
 
LVL 12

Author Comment

by:str_kani
ID: 17360601
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
 
LVL 28

Accepted Solution

by:
FishMonger earned 200 total points
ID: 17361130
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
 
LVL 17

Expert Comment

by:mjcoyne
ID: 17364108
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now