From steve at devon-it.co.uk Thu Jul 20 05:23:23 2006 From: steve at devon-it.co.uk (Steve Marvell) Date: Thu, 20 Jul 2006 13:23:23 +0100 Subject: [DCPM] windows newlines in #! line Message-ID: <20060720122323.GA31115@devon-it.co.uk> This started as a CGI problem. Apparently, some of the Perl scripts a particular company provide are littered with Windows newlines. This casuse a bad interpretor error. This is also the case if the script is run by hand. I understand that the present version of a Apache the clinet is using handles this. I take this is a shell problem, but I think it could be solved if Apache prestripped them Anyone got any ideas? Steve From simon at technocool.net Thu Jul 20 12:07:42 2006 From: simon at technocool.net (Simon Waters) Date: Thu, 20 Jul 2006 20:07:42 +0100 Subject: [DCPM] windows newlines in #! line In-Reply-To: <20060720122323.GA31115@devon-it.co.uk> References: <20060720122323.GA31115@devon-it.co.uk> Message-ID: <44BFD47E.7010401@technocool.net> Steve Marvell wrote: > This started as a CGI problem. Apparently, some of the Perl scripts a > particular company provide are littered with Windows newlines. This > casuse a bad interpretor error. > > This is also the case if the script is run by hand. > > I understand that the present version of a Apache the clinet is using > handles this. > > I take this is a shell problem, but I think it could be solved if > Apache prestripped them > > Anyone got any ideas? The usual cause is incorrectly transferring the files to the server. ftp will correctly translate text files, but if they are shipped up as a zip file then the transfer is skipped. Just; find . -name "*.pl" -print0 | xargs -0 dos2unix Or whatever appropriate pattern is required for the find. From user_groups at pm.org Thu Jul 20 12:24:04 2006 From: user_groups at pm.org (Dave Cross) Date: Thu, 20 Jul 2006 20:24:04 +0100 Subject: [DCPM] windows newlines in #! line In-Reply-To: <20060720122323.GA31115@devon-it.co.uk> References: <20060720122323.GA31115@devon-it.co.uk> Message-ID: <44BFD854.70200@pm.org> Steve Marvell wrote: > This started as a CGI problem. Apparently, some of the Perl scripts a > particular company provide are littered with Windows newlines. This > casuse a bad interpretor error. > > This is also the case if the script is run by hand. > > I understand that the present version of a Apache the clinet is using > handles this. > > I take this is a shell problem, but I think it could be solved if > Apache prestripped them > > Anyone got any ideas? The problem is that your shebang line has a Windows newline character on the end. It therefore looks something like this: #!/usr/bin/perl\r\n Unix recognises the \n as the end of the line and therefore looks for a program called /usr/bin/perl\r And (usually) that doesn't exist. Of course, you shouldn't be seeing this problem as your shebang line should look like this: #/usr/bin/perl -T\r\n In this case, the shell correctly extracts the path to Perl and passes the slight broken command line argument (-T\r) to Perl. Perl can deal with broken line endings just fine, so this will fix the problem. Of course, you'll then find that your program isn't taint-clean and that'll give you some far more serious problems to fix :) Dave... From steve at devon-it.co.uk Fri Jul 21 03:50:22 2006 From: steve at devon-it.co.uk (Steve Marvell) Date: Fri, 21 Jul 2006 11:50:22 +0100 Subject: [DCPM] windows newlines in #! line In-Reply-To: <44BFD47E.7010401@technocool.net> References: <20060720122323.GA31115@devon-it.co.uk> <44BFD47E.7010401@technocool.net> Message-ID: <20060721105021.GB24782@devon-it.co.uk> Simon Waters wrote: > The usual cause is incorrectly transferring the files to the server. ftp > will correctly translate text files, FTP server or client? > find . -name "*.pl" -print0 | xargs -0 dos2unix That's good for me, but not good for downstream box users who are just web clients. Steve From dave at dave.org.uk Sat Jul 22 13:52:36 2006 From: dave at dave.org.uk (Dave Cross) Date: Sat, 22 Jul 2006 21:52:36 +0100 Subject: [DCPM] windows newlines in #! line In-Reply-To: <20060720122323.GA31115@devon-it.co.uk> References: <20060720122323.GA31115@devon-it.co.uk> Message-ID: <44C29014.10000@dave.org.uk> Steve Marvell wrote: > This started as a CGI problem. Apparently, some of the Perl scripts a > particular company provide are littered with Windows newlines. This > casuse a bad interpretor error. > > This is also the case if the script is run by hand. > > I understand that the present version of a Apache the clinet is using > handles this. > > I take this is a shell problem, but I think it could be solved if > Apache prestripped them > > Anyone got any ideas? The problem is that your shebang line has a Windows newline character on the end. It therefore looks something like this: #!/usr/bin/perl\r\n Unix recognises the \n as the end of the line and therefore looks for a program called /usr/bin/perl\r And (usually) that doesn't exist. Of course, you shouldn't be seeing this problem as your shebang line should look like this: #/usr/bin/perl -T\r\n In this case, the shell correctly extracts the path to Perl and passes the slight broken command line argument (-T\r) to Perl. Perl can deal with broken line endings just fine, so this will fix the problem. Of course, you'll then find that your program isn't taint-clean and that'll give you some far more serious problems to fix :) Dave...