"Miguel Cruz" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > On Wed, 27 Mar 2002, Dalton Hunter wrote: > > Hi, I am trying to write a file that contains a shell script. The file > > writes to the server but when I try to execute it it fails with a > > command not found error. But if I copy and paste the files contents into > > a new text file using Textpad on my PC and upload it to the same > > directory it works?! It is not related to permissions as both files are > > 777 and I am root? The only difference I could tell is when I compare > > the files in Textpad although the contents are identical, the failed > > file is slightly larger and has a file type of "Netscape" in the File > > Properties while the other has a file type of "PC"? Any ideas? > > Make sure you use unix-style line endings (just \n and no \r). > > Textpad sort of transparently opens files with different line ending > styles, though it does tell you in one of those little status boxes at the > bottom - if it's showing DOS or Windows or whatever when you open it, then > the shell probably won't execute it. > > An alternative would be to use text/ASCII (not binary) FTP to transfer it > to the server. This will automatically fix the line endings. > > miguel >
Hi, thanks for your reply. I should have been a little clearer. The file is created as a result of a PHP script not in TextPad. I am only comparing them in Textpad afterward. For example the script contains ... <?php // BEGIN PHP SCRIPT THAT GENERATES SHELL SCRIPT $sbackup = "#!/bin/sh ... multiple line shell script in here ... "; $backupfile = fopen("/path/to/shell_script","w"); fwrite($backupfile,$sbackup); fclose($backupfile); chmod("/path/to/shell_script", 0777); // END PHP SCRIPT THAT GENERATES SHELL SCRIPT ?> ... and it creates the file fine but when I go to execute the shell script it returns ... sh: ./shell_script: No such file or directory eventhough it is there. If I copy the files contents into a new Texpad document on my PC and upload to the server it works fine. I tried to add a \n at the end of each line in the PHP script but no luck. I think it might have something to do with the line endings. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.343 / Virus Database: 190 - Release Date: 3/22/02 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php