[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: writing to /dev/stdout fails in cron script



Tony van der Hoff <tony@vanderhoff.org> wrote:

> Running up-to-date Wheezy.

> I have a script, simplified like this:

> -----------------------------
> #!/bin/bash
> DEBUG=1

> OUT=/dev/null

> if [ $DEBUG -ne 0 ]; then
>        OUT=/dev/stdout
> fi

> echo hello > $OUT
> -----------------------------

> This works fine when invoked from the command line, but when called as a
> cron task, same user, it fails with
> /home/tony/scripts/test: line 10: /dev/stdout: Permission denied

What is /dev/stdout on your system? It should look like this:

~$ ls -al /dev/stdout
lrwxrwxrwx 1 root root 15 Aug  6 23:06 /dev/stdout -> /proc/self/fd/1

Maybe the symlink was replaced by a file with insufficient permissions,
thus the error.

If that is the case, please remove the file and recreate the symlink.
(Or reboot, since /dev should be on a tmpfs the symlink will be created
at boot time.)

_If_ the symlink is correctly in place as show above, please provide the
output of "ls -ald /dev", maybe the permissions to /dev are wrong.

Grüße,
Sven.

-- 
Sigmentation fault. Core dumped.


Reply to: