Sponsored Content
Full Discussion: at reminder script
Homework and Emergencies Homework & Coursework Questions at reminder script Post 302561630 by csharp100 on Tuesday 4th of October 2011 04:14:26 PM
Old 10-04-2011
Ok, so I got the last problem straightened out and now I have another. It seems I am so close yet so far away. Here is my code;
Code:
#!/usr/dt/bin/dtksh
# Alertme.p1 program, version 0.5
# Author - Clint Sharp
mkdir ~/Msgs
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 -k $TIME << !!
who | cut -c1-20 | grep $LOGNAME | cut -c12-20 | cat > ~/tmp
while read inputline
do
        write $LOGNAME $inputline < ~/Msgs/message.$$ #|| mail $inputline < ~/Msgs/message.$$
done < ~/tmp
rm -r ~/Msgs
rm -r ~/tmp
exit 0

What is happening is I will have two terminal sessions opened to test this script and it is sending two messages to the same terminal. The one that originally initiated the script. I also get a mail message that says,
Code:
Your "at" job on admiral
"/var/spool/cron/atjobs/1317758851.a"
produced the following output:
I cannot determine your terminal name. No reply possible.
cs368 is logged on more than one place.
You are connected to "pts/26".
Other locations are:
pts/98Warning: You have your terminal set to "mesg -n". No reply possible.
I cannot determine your terminal name. No reply possible.
cs368 is logged on more than one place.
You are connected to "pts/26".
Other locations are:
pts/98Warning: You have your terminal set to "mesg -n". No reply possible.

On the terminal pts/98 I did change message to "yes" using the -y switch. I do not think this is the problem though. Can anyone help?
 

2 More Discussions You Might Find Interesting

1. 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

2. 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
mktemp(3C)						   Standard C Library Functions 						mktemp(3C)

NAME
mktemp - make a unique file name from a template SYNOPSIS
#include <stdlib.h> char *mktemp(char *template); DESCRIPTION
The mktemp() function replaces the contents of the string pointed to by template with a unique file name, and returns template. The string in template should look like a file name with six trailing 'X's; mktemp() will replace the 'X's with a character string that can be used to create a unique file name. Only 26 unique file names per thread can be created for each unique template. RETURN VALUES
The mktemp() function returns the pointer template. If a unique name cannot be created, template points to a null string. ERRORS
No errors are defined. EXAMPLES
Example 1 Generate a filename. The following example replaces the contents of the "template" string with a 10-character filename beginning with the characters "file" and returns a pointer to the "template" string that contains the new filename. #include <stdlib.h> ... char *template = "/tmp/fileXXXXXX"; char *ptr; ptr = mktemp(template); USAGE
Between the time a pathname is created and the file opened, it is possible for some other process to create a file with the same name. The mkstemp(3C) function avoids this problem and is preferred over this function. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ SEE ALSO
mkstemp(3C), tmpfile(3C), tmpnam(3C), attributes(5), standards(5) SunOS 5.11 15 Sep 2004 mktemp(3C)
All times are GMT -4. The time now is 03:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy