at reminder script

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions at reminder script
# 1  
Old 09-30-2011
at reminder script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
Hi everyone, The script I did below works just fine. My problem is when the script is executed, I receive 2 emails. One is from the script and the other is from our Sun OS system named admiral. The Sun os is ver. 5.10. The mail message I receive is:
"Your "at" job on admiral
"/var/spool/cron/atjobs/1317352641.a"
produced the following output:
stty: : Inappropriate ioctl for device
stty: : Inappropriate ioctl for device
I cannot determine your terminal name. No reply possible.
Warning: You have your terminal set to "mesg -n". No reply possible."

I am trying to figure out what "stty: :In appropriate ioctl for device" means. Can anyone help? Thanks!


2. Relevant commands, code, scripts, algorithms:

at command

3. The attempts at a solution (include all code and scripts):
Code:
# Alertme.p1 program, version 0.3
# Author - Clint Sharp
echo "\nEnter your reminder message.
When finished, enter a period (.) at
the beginning of a line and press <ENTER>.
(Or press Ctrl-C to exit the script)\n"
while :
do
        read MESSAGE
        if [ "$MESSAGE" = "." ]
        then
                break
        else
                echo $MESSAGE >> ~/Msgs/message.$$
        fi
done
echo "\nEnter the time and day you want to
receive the message, for example:
0815am Jun 14
8:15am Jun 14
now + 1 day
5 pm Friday
Then press <ENTER>\n"
read TIME 
echo "\nAt $TIME mail or write $LOGNAME ~/Msgs/message.$$\n"
at $TIME << !!
write $LOGNAME < ~/Msgs/message.$$ || mail $LOGNAME < ~/Msgs/message.$$
rm -f ~/Msgs/message.$$
exit 0


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
UMSL, St Louis, MO, USA, Antonogli, cs2750

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 09-30-2011
It's write that's doing it, printing error messages that get logged. It wouldn't be sending two emails if write wasn't failing, after all.

Redirect it's output into /dev/null. write $LOGNAME < ~/Msgs/message.$$ > /dev/null 2> /dev/null ...
# 3  
Old 09-30-2011
That did not solve my problem. I may not have explained it correctly so I will try again. The script is to send a reminder to me using the at command. If I am online, then it will write to me. If I am offline, then it will email me. If I am online, the script will "interrupt me" with the reminder but it also sends a mail message with the aforementioned, "stty: :Inappropriate ioctl for device". If I am offline, the script mails me two messages. The original reminder and the "stty: :Inappropriate ioctl for device" message.
When I tried the above code suggested by Corona688, I got no message and received a mail message, "Ambiguous output redirect." Therefor I am stuck.

Last edited by csharp100; 09-30-2011 at 12:36 PM..
# 4  
Old 09-30-2011
Show me exactly what you tried.

---------- Post updated at 02:02 PM ---------- Previous update was at 02:00 PM ----------

Quote:
Originally Posted by csharp100
That did not solve my problem. I may not have explained it correctly so I will try again.
I think I understood in the first place.

write is trying to terminal commands on a non-terminal device(being run from 'at', it has no terminal!) which isn't the end of the world, but also blabs error messages when it does, which isn't what you want.

The redirection I showed you ought to work, but may have gone into the wrong place, can you show me exactly what you tried?
# 5  
Old 09-30-2011
Quote:
Originally Posted by Corona688
Show me exactly what you tried.

---------- Post updated at 02:02 PM ---------- Previous update was at 02:00 PM ----------

I think I understood in the first place.

write is trying to terminal commands on a non-terminal device(being run from 'at', it has no terminal!) which isn't the end of the world, but also blabs error messages when it does, which isn't what you want.

The redirection I showed you ought to work, but may have gone into the wrong place, can you show me exactly what you tried?
I tried,
Code:
 write $LOGNAME < ~/Msgs/message.$$ > /dev/null 2>dev/null

and
Code:
 write $LOGNAME < ~/Msgs/message.$$ > /dev/null 2>&1

I did take out the
Code:
 || mail $LOGNAME < ~/Msgs/message.$$

on both tries.
When I tried both, I got the same message mailed to me and did not get my write message at all. It also included an "Ambiguous redirection" in the mail messages as well.
# 6  
Old 09-30-2011
How strange. Those are perfectly valid redirects. What shell are you using?

You do this, up at the top of your script, before you run anything else:

Code:
exec 2>/dev/null

Which will force all stderr output to /dev/null.
# 7  
Old 09-30-2011
The script should be korn
Code:
#!/usr/dt/bin/dtksh

Sorry, for some reason I missed that in the cut and paste.
The system tells me:
Code:
commands will be executed using /bin/csh

Come to think of it, wonder if that is my problem?
Login or Register to Ask a Question

Previous Thread | Next Thread

2 More Discussions You Might Find Interesting

1. OS X (Apple)

A simple reminder script for beginners to shell scripting.

(Apologies for any typos.) Well hands up those who have been in the following situation(s):- Your partner, (in my case the missus), sees that you are messing with your machine and says something like, "can you keep an eye on the dinner, I am going out shopping", and you look up glazed eyed... (3 Replies)
Discussion started by: wisecracker
3 Replies

2. Homework & Coursework Questions

Reminder script not working...

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: We have been tasked to write an at reminder script that will write or echo a message to more than one user. What... (11 Replies)
Discussion started by: csharp100
11 Replies
Login or Register to Ask a Question