Thursday, May 9, 2024
 Popular · Latest · Hot · Upcoming
40
rated 0 times [  40] [ 0]  / answers: 1 / hits: 33551  / 1 Year ago, fri, may 19, 2023, 12:47:32

Trying to get casperjs running on Ubuntu 12.04. After installing it when I run I get:



09:20 $ ll /usr/local/bin/casperjs
lrwxrwxrwx 1 root root 26 Nov 6 16:49 /usr/local/bin/casperjs -> /opt/casperjs/bin/casperjs

09:20 $ /usr/bin/env python --version
Python 2.7.3

09:20 $ cat /opt/casperjs/bin/casperjs | head -4
#!/usr/bin/env python

import os
import sys

09:20 $ casperjs
: No such file or directory

09: 22 $ python
Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2


So Python is present and runnable, casperjs is pointing to the right place and it is a python script. But when I run it I get "No such file".



I can fix it by changing the first line of the casperjs python file from:



#!/usr/bin/env python


to:



#!/usr/bin/python


Result:



$ casperjs --version
1.1.0-DEV


I managed to fix it, but I'm wondering why it didn't work with #!/usr/bin/env python, since that seems to be a normal interpreter line. Do I have something configured wrong?



Here are the steps to get casperjs:



$ git clone git://github.com/n1k0/casperjs.git
$ cd casperjs
$ ln -sf `pwd`/bin/casperjs /usr/local/bin/casperjs
$ casperjs
: No such file or directory

More From » bash

 Answers
6

If you see the error “: No such file or directory” (with nothing before the colon), it means that your shebang line has a carriage return at the end, presumably because it was edited under Windows (which uses CR,LF as a line separator). The CR character causes the cursor to move back to the beginning of the line after the shell prints the beginning of the message and so you only get to see the part after CR which ends the interpreter string that's part of the error message.



Remove the CR: the shebang line needs to have a Unix line ending (linefeed only). Python itself allows CRLF line endings, so the CR characters on other lines don't hurt. Shell scripts on the other hand must be free of CR characters.



To remove the Windows line endings, you can use dos2unix:



sudo dos2unix /usr/local/bin/casperjs


or sed:



sudo sed -i -e 's/
$//' /usr/local/bin/casperjs


If you must edit scripts under Windows, use an editor that copes with Unix line endings (i.e. something less brain-dead than Notepad) and make sure that it's configured to write Unix line endings (i.e. LF only) when editing a Unix file.


[#28519] Saturday, May 20, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
fulild

Total Points: 239
Total Questions: 103
Total Answers: 112

Location: Papua New Guinea
Member since Thu, Jul 9, 2020
4 Years ago
fulild questions
Sat, Dec 11, 21, 20:10, 2 Years ago
Thu, Jun 17, 21, 12:05, 3 Years ago
Sat, Nov 19, 22, 16:28, 2 Years ago
Sat, Feb 25, 23, 22:59, 1 Year ago
Wed, Oct 12, 22, 04:04, 2 Years ago
;