Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identical 4 line script does not run.

Status
Not open for further replies.

voltolio

Technical User
Feb 5, 2008
4
0
0
I can download a script off the web, ftp it to the host, and it runs fine. If I open the script on the PC (using either notepad, wordpad, or even a perl editor), do nothing to it, save it, and then ftp again, it will not run. The host supplied a simple script which ran fine. I did the same thing (as mentioned above) with the same script and even it did not run. Here is the script:

#!/usr/bin/perl

print "Content-type: text/html\n\n";
print "Greetings user.\n";

If I 'view' the scripts (the ones that run and the ones that don't) as they exist on the host, everything is identical.

How can something so simple not run?

All settings are identical to the scripts that did run (chmod, ascii upload, etc.)

Thanks!
 
Upload the perl script in ASCII mode and set file permission to 755 if necessray. If you use a program like wordpad make sure to save the file in 'txt' format and not 'doc' format.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Ascii mode - previously Done
permission 755 - previously done
identical files that either run or don't have .cgi extension

 
Try uploading in binary mode then. If that does not work and the two files are identical in every way I have no idea why one works and the other does not.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Is it a Unix (or AIX, Linux et al) host by any chance?

If so, you need to use an editor that can save files in unix format. Windows text files terminate each line with a CR and a LF character. Unix uses only the LF character, meaning you can be left with a ^M on the end of each line which can confuse Perl.

I think there's a utility you can run to strip the rogue characters out, but the best way is never to put them in in the first place. Any decent editor (i.e. not Notepad or Wordpad) should be able to do this - personally I use Notetab.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
The host is Godaddy, Linux. I'm using a trial of EnginSite Perl Editor, but also did that open/save on that 4 line script I mentioned with notepad. I did notice the extra CR at the end and took it out. Reopened, CR gone. Uploaded (SmartFTP), no go.

What really throws me here is an unopened program from the web can go from my PC, through the ftp, to the host, and it runs fine.

Just the simple act of opening and saving a file here on this PC (aside from that CR) ruins the script somehow. That's why I tried that 4 liner - how much more simple than that can you get? Baffling!

Thanks for your responses.
 
I write and save text files all the time on my windows PC and transfer them to a Linux/Unix server with no problems. WS_FTP translates the line endings during the file transfer. I have used SmartFTP in the past with the same results. I am not sure what else to say.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
I GOT IT!

After the file transfers if I click on it on the server side a window opens and asks if I want to overwrite it. It shows the original file with the .cgi icon and the overwrite file with the .txt icon. I chose overwrite. Now it works.

I don't know why this makes it work as again, both files are visually identical.

Maybe something peculiar with the host.

Thanks for all!

Voltolio
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top