# File not found by run_rc_command



## gmele (Nov 3, 2011)

I'm having trouble with an rc script that is meant to start a python daemon.  The script is a modified copy of an existing one that works.  Only the names have been changed to ...
My system is FreeBSD 8.2. 

The script is names pycron

```
#!/bin/sh

# PROVIDE: pycron
# REQUIRE: DAEMON mysql
# KEYWORD: shutdown

. /etc/rc.subr

name="pycron"
rcvar=`set_rcvar`
command="/usr/local/www/pycron/${name}.py"
command_interpreter="/usr/local/bin/python"

pidfile=/var/run/${name}.pid

load_rc_config $name
run_rc_command "$1"
```

When run with debugging on, using:
`# /usr/local/etc/rc.d/pycron start`

```
/usr/local/etc/rc.d/pycron: DEBUG: in run_rc_command: pidcmd is (rc_pid=$(check_pidfile /var/run/pycron.pid /usr/local/www/pycron/pycron.py python))
/usr/local/etc/rc.d/pycron: DEBUG: pid file (/var/run/pycron.pid): not readable.
/usr/local/etc/rc.d/pycron: DEBUG: checkyesno: pycron_enable is set to yes.
Starting pycron.
/usr/local/etc/rc.d/pycron: DEBUG: run_rc_command: doit: /usr/local/www/pycron/pycron.py  
eval: /usr/local/www/pycron/pycron.py: not found
/usr/local/etc/rc.d/pycron: WARNING: failed to start pycron
```

The file pycron does exist.  
`# ll /usr/local/www/pycron/`

```
-rwxr-xr-x  1 root  wheel  840 Nov  3 10:11 /usr/local/www/pycron/pycron.py
```

I've run out of ideas.  Can anyone help, please.


----------



## idle (Nov 3, 2011)

What is in /usr/local/www/pycron/pycron.py? Check its shebang (first line).


----------



## gmele (Nov 3, 2011)

Wow...
Thanks for the quick reply.

The first line looks ok.  It is

```
#!/usr/local/bin/python
```

It starts ok manually using `# python pycron.py`


----------



## idle (Nov 3, 2011)

Check it that way:
[cmd=""]# /usr/local/www/pycron/pycron.py[/cmd]


----------



## gmele (Nov 3, 2011)

You are correct. Trying to start with `/usr/local/www/pycron/pycron.py` does not work. The error is 
	
	



```
Command not found
```

I have another python daemon with an identical first line that does start using its name. Both files have the same owner, group and permissions, but are in different directories.  The owner, group and permissions for the two directories are the same.

One works, the other doesn't.  I can't think of a reason for this?


----------



## idle (Nov 3, 2011)

gmele said:
			
		

> I can't think of a reason for this???


Perhaps some hidden symbols.
Or it is output not from first line, but one of the following.


----------



## gmele (Nov 3, 2011)

*Solved*

Found the problem.

There is an ^M at the end of every line in the file.
FTP is supposed to take those out.


----------



## wblock@ (Nov 3, 2011)

gmele said:
			
		

> Found the problem.
> 
> There is an ^M at the end of every line in the file.
> FTP is supposed to take those out..............



Only in text mode.


----------



## phoenix (Nov 4, 2011)

converters/unix2dos works wonders on files like this.


----------



## ikreos (Nov 4, 2011)

You could also use tr(1).


----------

