Link to home
Start Free TrialLog in
Avatar of angelmoon
angelmoonFlag for Canada

asked on

Perl script gives error in cron

Hello,

I have a perl script which gives me the following error when it runs in cron:

write: can't find your tty

The purpose of the script is to send a notification to sysadm via the write unix command.

The script is as follows:
#!/usr/local/bin/perl
$username = "sysadm";
$message = "here";
  open term, "|/usr/bin/write $username";
  print term $message;
  close term;
exit;

Any ideas on a fix?

Thanks,
Angelmoon
Avatar of kandura
kandura

not a perl problem: try this shell script instead, it won't work either. the reason is that CRON runs as a daemon, so isn't attached to a tty.

#!/bin/sh

MESG="here"
USER="sysadm"
echo $MESG | write $USER

Avatar of angelmoon

ASKER

Thanks, kandura. I figured that out yesterday. I discovered that wall -g command works, so I am using that to broadcast a message.
In that case, I suggest you ask for your question to be removed and your points refunded.
I'm just glad I didn't have to go figure out how to find and open tty's ;^)
ASKER CERTIFIED SOLUTION
Avatar of GhostMod
GhostMod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial