Perl script gives error in cron

Posted on 2004-11-25
Last Modified: 2012-06-21

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:
$username = "sysadm";
$message = "here";
  open term, "|/usr/bin/write $username";
  print term $message;
  close term;

Any ideas on a fix?

Question by:angelmoon
    LVL 18

    Expert Comment

    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.


    echo $MESG | write $USER


    Author Comment

    Thanks, kandura. I figured that out yesterday. I discovered that wall -g command works, so I am using that to broadcast a message.
    LVL 18

    Expert Comment

    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 ;^)
    LVL 1

    Accepted Solution

    Closed, 125 points refunded.

    Community Support Moderator

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
    There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now