Link to home
Start Free TrialLog in
Avatar of joedunn
joedunn

asked on

Edit a Perl File then Upload via FTP

I am trying to do something that should be simple.  However, I am trying to do it so it is not.

1.  I am trying to implement a formmail script called:  NMS Formmail.  It can be found here:  http://nms-cgi.sourceforge.net/
2.  I think my problem is that when I edit the formmail.pl file I am using the wrong editor and/or saving it incorrectly and/or uploading to the server incorrectly.  Here is what I am doing:



1.  Edit formmail.pl with Notepad
2.  I make the changes I believe are necessary according to the directions.
3.  I click on Save As and select these options:
            File Name:  formmail
       Save as Type:  Text Documents (*.txt)
              Encoding:  Ansi

4.  I then upload via FTP in BINARY mode to my host server.  The server shows the file as a PL file but it does not work AT ALL.  It is not a configuration problem with the file.  It is uploaded to the correct cgi-bin directory.  I am uploading the darn file or saving it incorrectly I am sure.  Can someone help?

 

Avatar of ozo
ozo
Flag of United States of America image

Try FTPing as TEXT instead of BINARY
Avatar of joedunn
joedunn

ASKER

That's not it :(
Hi joedunn,

Try setting the permission of your script to executable on the server: On Unix server, use "chmod 0755 myscript.pl", On Window server, make sure the dir you uploaded to has permission to run scripts.  You can likely use your FTP client to set the permission if you don't have shell access to the server.

BTW, the TEXT/BINARY mode should not matter in this case.

Cheers!
Avatar of joedunn

ASKER

I thought of CHMOD and went to the extreme and tried 777.  No luck.
What error do you get?
Can you run the program from the command line?
Avatar of joedunn

ASKER

You can try it out here, its a very simple test form:

www.summitre.com/vera.htm
joedunn,

Check the first line of the script.  Does it have something like "#!/usr/bin/perl"?  If not, put it in.  If it does, verify if that line points to the correct perl binary.
Did you see if
More information about this error may be available in the server error log.
ASKER CERTIFIED SOLUTION
Avatar of Tintin
Tintin

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Tintin, while it's true the perl script would have DOS newline, but what does it matter anyway?  That for sure's not the problem (and if you read OP's later comment, indeed it made no difference as I suggested) 'cause perl interpreter's smart enough not to be tricked by this small cross-platform issue.

I agree with ozo, if joedunn tried my suggestions and they don't work, joe should try to check server log (or use fatalstobrowser and see if it catches error.  Sometimes it doesn't (like when the problem's due to #! line)).
inq123.

I can assure you that a Perl script on a Unix system that has

#!/usr/bin/perl

as the first line will not work if it has Windows end of line characters and is FTP'ed in binary mode.

The reason is that the Unix kernel will be looking for an interpreter called

/usr/bin/perl<CR>

where <CR> is a carriage return.

Sometimes, people can be fooled into thinking the windows end of line characters don't matter if they have any flags on the first line, eg:

/usr/bin/perl -w

The Unix kernel will now correctly see the interpretor as:

/usr/bin/perl

and perl will quite happily handle parsing the flag

-w<CR>
Yeah, Tintin, you're right.  I'm just surprised why OP's first attempt at FTP as text not binary failed to work.  ozo deserves some credit too then.