How to port scripts written for UNIX on windows

Discussion in 'Perl Misc' started by karuna, Jun 1, 2005.

  1. karuna

    karuna Guest

    Hi

    I have written nearly 70 perl scripts which run well on UNIX
    platforms. But on windows(2000/03 and XP) am finding lot of problem.

    I am ending up rewriting code with too much of modification.

    What is the solution for this ?.

    Those who know kindly reply back to me ..

    Thanks
    Karuna
     
    karuna, Jun 1, 2005
    #1
    1. Advertising

  2. karuna

    Brian Wakem Guest

    karuna wrote:

    > Hi
    >
    > I have written nearly 70 perl scripts which run well on UNIX
    > platforms. But on windows(2000/03 and XP) am finding lot of problem.
    >
    > I am ending up rewriting code with too much of modification.
    >
    > What is the solution for this ?.



    Write portable code. Of course it's too late as you've already it. Do you
    have any specific problems? code examples?


    --
    Brian Wakem
     
    Brian Wakem, Jun 1, 2005
    #2
    1. Advertising

  3. karuna

    Brian Wakem Guest

    Brian Wakem wrote:

    > Of course it's too late as you've already it.



    .....already written it.


    --
    Brian Wakem
     
    Brian Wakem, Jun 1, 2005
    #3
  4. karuna wrote:
    > I have written nearly 70 perl scripts which run well on UNIX
    > platforms. But on windows(2000/03 and XP) am finding lot of problem.
    >
    > I am ending up rewriting code with too much of modification.


    Do you have examples of pieces that you have to rewrite?

    > What is the solution for this ?.


    Simple. Don't write non-portable Perl code to begin with. Doesn't help you
    much now, but that is really the underlying problem.

    For details please see "perldoc perlport"

    jue
     
    Jürgen Exner, Jun 1, 2005
    #4
  5. karuna

    Tintin Guest

    "karuna" <> wrote in message
    news:...
    > Hi
    >
    > I have written nearly 70 perl scripts which run well on UNIX
    > platforms. But on windows(2000/03 and XP) am finding lot of problem.
    >
    > I am ending up rewriting code with too much of modification.
    >
    > What is the solution for this ?.


    Write portal code to start with.

    Don't call external programs that can be done natively in Perl.

    Use configuration files so you don't have to hardcode settings in the Perl
    scripts.
     
    Tintin, Jun 2, 2005
    #5
  6. karuna

    Anno Siegel Guest

    Tintin <> wrote in comp.lang.perl.misc:
    >
    > "karuna" <> wrote in message
    > news:...
    > > Hi
    > >
    > > I have written nearly 70 perl scripts which run well on UNIX
    > > platforms. But on windows(2000/03 and XP) am finding lot of problem.
    > >
    > > I am ending up rewriting code with too much of modification.
    > >
    > > What is the solution for this ?.

    >
    > Write portal code to start with.


    Portal code? Do you mean "portable"?

    Anno
     
    Anno Siegel, Jun 2, 2005
    #6
  7. karuna

    Tintin Guest

    "Anno Siegel" <-berlin.de> wrote in message
    news:d7mkhn$340$-Berlin.DE...
    > Tintin <> wrote in comp.lang.perl.misc:
    >>
    >> "karuna" <> wrote in message
    >> news:...
    >> > Hi
    >> >
    >> > I have written nearly 70 perl scripts which run well on UNIX
    >> > platforms. But on windows(2000/03 and XP) am finding lot of problem.
    >> >
    >> > I am ending up rewriting code with too much of modification.
    >> >
    >> > What is the solution for this ?.

    >>
    >> Write portal code to start with.

    >
    > Portal code? Do you mean "portable"?


    Doh! I've been working on too many web portals recently.
     
    Tintin, Jun 2, 2005
    #7
  8. karuna

    karuna Guest

    Hi

    Thanks for your replies
    the problem is on unix suppose am using the path as "/opt/OV/bin"
    on windows it becomes "C:/Prog Files/Product Name/bin"

    and all scalar variables need to be enclosed with escape sequence
    for eg : a variable called $BIN need to be used as \"$BIN\"
    this is becomming a big pain.
    IS there is any way in windows or any API is there which could solve
    my problem

    Or normally how perl scripts will be written which work both on unix
    and
    windows ...
    Karuna
     
    karuna, Jun 3, 2005
    #8
  9. karuna wrote:
    > Thanks for your replies
    > the problem is on unix suppose am using the path as "/opt/OV/bin"
    > on windows it becomes "C:/Prog Files/Product Name/bin"


    Well, obviously calling external programs is not portable. Period.

    "Doctor, if I do this then it hurts."
    "Well, then don't do it."

    Use native Perl functions or modules instead.
    Or if those are custom programs for which there is no Perl equivalent, then
    define those pathes in one single configuration module. Then you have to
    change that one single file only.

    > and all scalar variables need to be enclosed with escape sequence
    > for eg : a variable called $BIN need to be used as \"$BIN\"


    What? Why do you think so?

    > this is becomming a big pain.
    > IS there is any way in windows or any API is there which could solve
    > my problem
    >
    > Or normally how perl scripts will be written which work both on unix
    > and
    > windows ...


    Well, did you actually read the FAQ that was pointed out to you? Or did you
    just thank people blindly without reading their suggestions?

    jue
     
    Jürgen Exner, Jun 3, 2005
    #9
  10. karuna

    Brian Wakem Guest

    karuna wrote:

    > Hi
    >
    > Thanks for your replies
    > the problem is on unix suppose am using the path as "/opt/OV/bin"
    > on windows it becomes "C:/Prog Files/Product Name/bin"
    >
    > and all scalar variables need to be enclosed with escape sequence
    > for eg : a variable called $BIN need to be used as \"$BIN\"
    > this is becomming a big pain.



    Can you give an example of where you need to do that?


    --
    Brian Wakem
     
    Brian Wakem, Jun 3, 2005
    #10
  11. karuna

    Guest

    "karuna" <> wrote:
    > Hi
    >
    > Thanks for your replies
    > the problem is on unix suppose am using the path as "/opt/OV/bin"
    > on windows it becomes "C:/Prog Files/Product Name/bin"


    That is not a OS-specific portability problem. You would have the same
    problem moving between two linux machines which had the directory installed
    in different places.

    > and all scalar variables need to be enclosed with escape sequence
    > for eg : a variable called $BIN need to be used as \"$BIN\"
    > this is becomming a big pain.


    I have no idea what you are trying to say here. Please include more perl
    context in your examples.

    Xho

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Jun 3, 2005
    #11
  12. karuna

    Tintin Guest

    "karuna" <> wrote in message
    news:...
    > Hi
    >
    > Thanks for your replies
    > the problem is on unix suppose am using the path as "/opt/OV/bin"
    > on windows it becomes "C:/Prog Files/Product Name/bin"


    Either create a configuration file where you can set all the appropriate
    settings, or use something like

    my $path;

    if ($^O =~ /Win/) {
    $path = "C:/Prog Files/Product Name/bin";
    }
    else {
    $path = "/opt/OV/bin";
    }
     
    Tintin, Jun 4, 2005
    #12
  13. gargoyle wrote:

    > On 2005-06-03, karuna <> wrote:
    >
    >>and all scalar variables need to be enclosed with escape sequence
    >>for eg : a variable called $BIN need to be used as \"$BIN\"
    >>this is becomming a big pain.
    >>IS there is any way in windows or any API is there which could solve
    >>my problem

    >
    >
    > You're using system() to run external programs? If that's the case,
    > maybe you can use the alternate syntax described in 'perldoc system',
    > like this:
    > system("command", "arg1", "arg2")
    > instead of this:
    > system("command arg1 arg2")


    You'd hope that wouldn't you, but it is not the case. Windows joins an
    resplits the list.
     
    Brian McCauley, Jun 4, 2005
    #13
  14. karuna

    Joe Smith Guest

    karuna wrote:

    > I have written nearly 70 perl scripts which run well on UNIX
    > platforms. But on windows(2000/03 and XP) am finding lot of problem.
    >
    > I am ending up rewriting code with too much of modification.


    I keep two instances of perl on my WinXP PC.
    1) ActiveState perl in C:\Perl\bin
    2) Cygwin perl in C:\cygwin\bin (aka /usr/bin)

    The second instance runs almost all of my Linux perl scripts
    on Windows with no changes.
    -Joe
     
    Joe Smith, Jun 4, 2005
    #14
  15. On Sat, 04 Jun 2005 12:25:27 +0200, Joe Smith <> wrote:

    > karuna wrote:
    >
    >> I have written nearly 70 perl scripts which run well on UNIX
    >> platforms. But on windows(2000/03 and XP) am finding lot of problem.
    >> I am ending up rewriting code with too much of modification.

    >
    > I keep two instances of perl on my WinXP PC.
    > 1) ActiveState perl in C:\Perl\bin
    > 2) Cygwin perl in C:\cygwin\bin (aka /usr/bin)
    >
    > The second instance runs almost all of my Linux perl scripts
    > on Windows with no changes.
    > -Joe



    Yes, cygwin is the great saviour for porting unix stuff to
    windows. Not just perl, but also bash and other stuff.

    http://www.cygwin.com/

    CygWin will also make i possible to use: perl -MCPAN -e shell
    to install things (together with gcc as well) instead of the
    activestate way, which is good, but many cpan modules are missing...


    I recommend CygWin for everyone who knows a bit of unix/linux,
    and who isn't happy at all with the crummy old black CMD (DOS)
    command line window (that is everyone, I suppose), but don't
    want to replace Windows with Linux eiher.

    Tip:
    Remember to install rxvt in cygwin. It will give you a white
    re-sizeable "bash-window" without going for the full X Windows package(s)
    and xterm. In the right-click-properties on a shortcut to rxvt on your
    desktop, use this or a similar thing as "target":

    C:\cygwin\bin\rxvt.exe -fn -12 -geometry 100x42 -sl 3000 -e bash -ls



    --
    Kjetil Skotheim
     
    Kjetil Skotheim, Jun 5, 2005
    #15
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve C. Orr, MCSD
    Replies:
    1
    Views:
    562
    reaway lee
    Aug 24, 2003
  2. vinay
    Replies:
    2
    Views:
    4,007
    =?ISO-8859-2?Q?Dra=BEen_Gemi=E6?=
    Jul 28, 2006
  3. Pom
    Replies:
    2
    Views:
    1,667
    Bas-i
    Jan 31, 2007
  4. KaiWen
    Replies:
    102
    Views:
    2,734
    Jorgen Grahn
    Sep 15, 2011
  5. Ren Patterson

    Perl scripts for Unix on my windows machine

    Ren Patterson, Oct 14, 2003, in forum: Perl Misc
    Replies:
    23
    Views:
    278
    Eric Bohlman
    Oct 17, 2003
Loading...

Share This Page