For Programmers: Free Programming Magazines  


Home > Archive > MacPerl > April 2005 > Advice for moving linux script to MacPerl









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Advice for moving linux script to MacPerl
ecurts@neo.rr.com

2005-03-27, 4:09 pm

Greetings!

I work for a public school where I have written a web-based CGI program
in perl that runs on our Linux web server. Another school would like
to use this program as well, but they have an OS9 server with
AppleShare IP. I have experience with Linux and Win2000/2003 but not
with OS9. Here is what I have done so far to help them, and the
problems I am having:

- I told them to download and install MacPerl, which they did.

- I then sent them a sample script to try out. It is a simple perl
script (printev.cgi) that prints the environment variables. I changed
the 'shebang' to fit the MacPerl syntax and used my text editor to save
the file in Mac format (to have the proper end of line character). The
script looks like this:

#!perl -w

print "Content-type: text/html\n\n";
print "<tt>\n";
foreach $key (sort keys(%ENV)) {
print "$key = $ENV{$key}<p>";
}

- Next I had them put the file in a web-accessible folder.

- Then I entered the URL for the file in my browser.

Here's where the problems started. The file did not get processed by
perl, but rather simply displayed in code format in the browser. The
server did not know what to do with the file, so it just displayed it
as text.

So here's what I did next:

- I had their tech guy start up MacPerl on the server, then open my
script file in MacPerl, then do a "Save As" and save the file in the
format "CGI Script".

- When looking at the new file it appears that MacPerl put a binary
"wrapper" around the original text file.

- He replaced the old script with this new file.

- I opened the URL in my browser and perl processed the file perfectly
this time.

So here's my question... Is this what you have to do to get perl
scripts to run on an OS9 server with AppleShare IP? If so then here's
the problem: My entire program is over 100 individual scripts. Will
their tech guy have to open each script one by one and resave in "CGI
Script" format?

In my experience with Linux and Win2000/2003 a perl script is always
just a text file. There is no need for a binary wrapper to make them
run.

Shouldn't the "shebang" just tell the web server to give the file to
MacPerl for processing, and allow me to send them all 100+ scripts as
simple text files (of course with the proper Mac end of lines)?

Thanks in advance for any help with this! I am sorry for my lack of
Mac knowledge and look forward to being enlightened.

Eric

Dave

2005-04-08, 9:00 pm

Hey Eric,

This sounds like a very simple MacOS issue. I am a Mac Guru, but NOT a
MacPERL Guru, so I may not completely understand, but I think I get it.

The issue seems to be the file type and creator. That, and not the .pl
file name extension determine which application opens a file on a Mac.

Step one - Verify that I am correct before making any changes. We have
to verify two things, that the file type and creator have been changed,
and that the file format has not been changed. In order to do this, the
tech will have to repeat the process without destroying the old file so
we have two files to compare. Next, drag both files onto BBEdit lite so
he can verify that the data in the files is exactlt the same.

File type and creator can be examined by using Sherlock (command-F in
the Finder), clicking on the edit button in the main window, then
dragging the files (one at a time) onto the "edit" window (More Search
Options). Look in the lower right hand corner for the type and creator.

Step two - If the files contents are exactly the same, use FileTyper (a
shareware tool) to change all the old files to the new file type.

If the tech is feeling adventurous, he could just skip step one, but he
should be careful to remember what the old type and creator were just in
case this does not work.

To change all the files at once, select them all in the Finder and drag
them to the FileTyper Icon. Make sure ONLY the Type and Creator
checkboxes are checked (he will have to uncheck a few). Click on the
Same As... button under the creator box, and select the file that has
already been converted. Then click on the Change All button in the
lower right corner. Boom! All done.

He can get FileTyper here...

http://www.versiontracker.com/php/s...tion=search&str
=FileTyper&plt%5B%5D=macos


Note that you may also have issues with directory name seperators (/ vs
:) in your scripts. This is a bug in MacPERL IMHO. Cwd() may help
with those issues...

Please post feedback if this works.

Thanks!

--Dave




In article <1110322629.252524.137970@g14g2000cwa.googlegroups.com>,
ecurts@neo.rr.com wrote:

> Greetings!
>
> I work for a public school where I have written a web-based CGI program
> in perl that runs on our Linux web server. Another school would like
> to use this program as well, but they have an OS9 server with
> AppleShare IP. I have experience with Linux and Win2000/2003 but not
> with OS9. Here is what I have done so far to help them, and the
> problems I am having:
>
> - I told them to download and install MacPerl, which they did.
>
> - I then sent them a sample script to try out. It is a simple perl
> script (printev.cgi) that prints the environment variables. I changed
> the 'shebang' to fit the MacPerl syntax and used my text editor to save
> the file in Mac format (to have the proper end of line character). The
> script looks like this:
>
> #!perl -w
>
> print "Content-type: text/html\n\n";
> print "<tt>\n";
> foreach $key (sort keys(%ENV)) {
> print "$key = $ENV{$key}<p>";
> }
>
> - Next I had them put the file in a web-accessible folder.
>
> - Then I entered the URL for the file in my browser.
>
> Here's where the problems started. The file did not get processed by
> perl, but rather simply displayed in code format in the browser. The
> server did not know what to do with the file, so it just displayed it
> as text.
>
> So here's what I did next:
>
> - I had their tech guy start up MacPerl on the server, then open my
> script file in MacPerl, then do a "Save As" and save the file in the
> format "CGI Script".
>
> - When looking at the new file it appears that MacPerl put a binary
> "wrapper" around the original text file.
>
> - He replaced the old script with this new file.
>
> - I opened the URL in my browser and perl processed the file perfectly
> this time.
>
> So here's my question... Is this what you have to do to get perl
> scripts to run on an OS9 server with AppleShare IP? If so then here's
> the problem: My entire program is over 100 individual scripts. Will
> their tech guy have to open each script one by one and resave in "CGI
> Script" format?
>
> In my experience with Linux and Win2000/2003 a perl script is always
> just a text file. There is no need for a binary wrapper to make them
> run.
>
> Shouldn't the "shebang" just tell the web server to give the file to
> MacPerl for processing, and allow me to send them all 100+ scripts as
> simple text files (of course with the proper Mac end of lines)?
>
> Thanks in advance for any help with this! I am sorry for my lack of
> Mac knowledge and look forward to being enlightened.
>
> Eric
>





--Dave

Java__Dave@NOSPAM_Hotmail.com

Remove NOSPAM_ to reply...
The 2 underscores in Java__Dave are required...
Dave

2005-04-09, 4:01 am

Whoa,

Nevermind....

Sorry about that. I should have realized I could check all that BEFORE
I posted.

Sincere appology...

I am wrong. You need to convert all the files, yes, it is putting a
binary wrapper on the script.


You should be able to do that with an AppleScript, but that does not
seem to work. MacPERL is very AppleScript friendly, and they will let
you script the opening of files and the saving of files as Runtime
files, but not as CGI files.

Dropping MacPERL onto the AppleScript Script Editor will display the
MacPERL AppleScript Dictionary, which includes Save window As Runtime,
but NOT as CGI.


By recording a script, I found that I can save the files as CGI files of
two differeent types:

Save document 1 in file "HD:" as «constant svasWWWÝ»
Save document 1 in file "HD:" as «constant svasWWW‡»

But neither seems to create a CGI file...

This looks like an oversight. I would guess that the CGI file options
were added after the AppleScript support, and that some minor updating
of the AppleScript abilities are in order.

So you will have to do the conversion manually.


That is very different...

HTH...

--Dave



In article
<Java__Dave-2659CD.16224608042005@newssvr21-ext.news.prodigy.com>,
Dave <Java__Dave@NOSPAM_hotmail.com> wrote:

> Hey Eric,
>
> This sounds like a very simple MacOS issue. I am a Mac Guru, but NOT a
> MacPERL Guru, so I may not completely understand, but I think I get it.
>
> The issue seems to be the file type and creator. That, and not the .pl
> file name extension determine which application opens a file on a Mac.
>
> Step one - Verify that I am correct before making any changes. We have
> to verify two things, that the file type and creator have been changed,
> and that the file format has not been changed. In order to do this, the
> tech will have to repeat the process without destroying the old file so
> we have two files to compare. Next, drag both files onto BBEdit lite so
> he can verify that the data in the files is exactlt the same.
>
> File type and creator can be examined by using Sherlock (command-F in
> the Finder), clicking on the edit button in the main window, then
> dragging the files (one at a time) onto the "edit" window (More Search
> Options). Look in the lower right hand corner for the type and creator.
>
> Step two - If the files contents are exactly the same, use FileTyper (a
> shareware tool) to change all the old files to the new file type.
>
> If the tech is feeling adventurous, he could just skip step one, but he
> should be careful to remember what the old type and creator were just in
> case this does not work.
>
> To change all the files at once, select them all in the Finder and drag
> them to the FileTyper Icon. Make sure ONLY the Type and Creator
> checkboxes are checked (he will have to uncheck a few). Click on the
> Same As... button under the creator box, and select the file that has
> already been converted. Then click on the Change All button in the
> lower right corner. Boom! All done.
>
> He can get FileTyper here...
>
> http://www.versiontracker.com/php/s...tion=search&str
> =FileTyper&plt%5B%5D=macos
>
>
> Note that you may also have issues with directory name seperators (/ vs
> :) in your scripts. This is a bug in MacPERL IMHO. Cwd() may help
> with those issues...
>
> Please post feedback if this works.
>
> Thanks!
>
> --Dave
>
>
>
>
> In article <1110322629.252524.137970@g14g2000cwa.googlegroups.com>,
> ecurts@neo.rr.com wrote:
>
>
>
>
>
> --Dave
>
> Java__Dave@NOSPAM_Hotmail.com
>
> Remove NOSPAM_ to reply...
> The 2 underscores in Java__Dave are required...





--Dave

Java__Dave@NOSPAM_Hotmail.com

Remove NOSPAM_ to reply...
The 2 underscores in Java__Dave are required...
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com