Reminder script not working...

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Reminder script not working...
# 1  
Old 10-31-2011
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 happens is the script does not write or echo the message to the entered users and sends a message to my inbox stating, "Your at job on admiral produced the following output: pts/62" pts/62 is the tty I am logged into. I never get the message. My message I enter into the script is "hello." While testing the script I have stayed online. Can anyone help me please?


2. Relevant commands, code, scripts, algorithms:
Not sure I understand this part.


3. The attempts at a solution (include all code and scripts):
Code:
Enter time: 
now + 1 min
Enter message: 
hello
Enter user(s): 
cs368
commands will be executed using /bin/ksh
job 1320104109.a at Mon Oct 31 18:35:09 2011
137 /accounts/students/c/cs368/alert.p2> more t1
#!/usr/dt/bin/dtksh
# Alert.p2 program, version 0.2
# Author - Clint Sharp
echo "\nEnter time: "
read TIME
echo "\nEnter message: "
read MESSAGE
echo "\nEnter user(s): "
read LOGNAMES
at -k $TIME << EOF
while read LOGNAME      
        do 
        who | grep $LOGNAME | sed 's,.*\(pts/[0-9]*\).*, \1 ,'
                while read tty
                        do
                        echo $MESSAGE | /dev/\$tty
                        done
        done
EOF


4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
UMSL, St Louis, MO, USA; Antognolij; 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 10-31-2011
As this is an assignment I'm only going to suggest that you look at a couple of things.

First, check the syntax of your echo statement. Think redirection.

Secondly, when at runs your script, what is the standard input? That might be a bit cryptic, so think about where the input to the while might be coming from. Remember, the script given to at doesn't have any variables that are in the script that you use to submit the job.
# 3  
Old 10-31-2011
Quote:
Originally Posted by agama
As this is an assignment I'm only going to suggest that you look at a couple of things.

First, check the syntax of your echo statement. Think redirection.
I corrected this with a ">" and appreciate that.
Quote:
Secondly, when at runs your script, what is the standard input? That might be a bit cryptic, so think about where the input to the while might be coming from. Remember, the script given to at doesn't have any variables that are in the script that you use to submit the job.
I'm not really quite sure what you are telling me here. Are you saying that the message is not getting into the at command?
# 4  
Old 10-31-2011
Quote:
I'm not really quite sure what you are telling me here. Are you saying that the message is not getting into the at command?
No, the contents of MESSAGE should be expanded as the here doc is read by at. Rereading, I see that my statement is confusing -- trying not to give away the store Smilie

No, in this case I'm trying to get you to see that the script executed by at has nothing to read. Unless I'm missing something, the user list that is input will never make it into your script. Think about how you might expand the contents of LOGNAMES as the script is written to at.
# 5  
Old 10-31-2011
Quote:
Originally Posted by agama
No, the contents of MESSAGE should be expanded as the here doc is read by at. Rereading, I see that my statement is confusing -- trying not to give away the store Smilie

No, in this case I'm trying to get you to see that the script executed by at has nothing to read. Unless I'm missing something, the user list that is input will never make it into your script. Think about how you might expand the contents of LOGNAMES as the script is written to at.
The only thing I can think of is to write the message to the disk and then have the message read off the disk when the job is executed. I have done that before but my professor was not to keen on writing to the disk even though I made a directory for the user of the at job and then removed the directory and its contents. I am not sure how else to do it.

My bad, I mis-read your message. But then again, the only thing I can think of is the same thing I wrote above about the message. Writing the names of the users to the disk and have them read into the at job at execution.
# 6  
Old 11-01-2011
Right, there's nothing to prevent the file from being deleted, so if you can avoid it you should. Most cases aren't as simple and writing out a state file is acceptable, but I see where your prof is coming from and agree.

Ok, so you know that the contents of MESSAGE will be expanded into the script as it is written to stdin when at is executed. You also know that your list of users is known when you invoke at, and that you could cause that list to be expanded into your script. So, is there another looping construct that you might be able to use in place of the while that would allow you to loop through the list of names?
# 7  
Old 11-01-2011
Quote:
Originally Posted by agama
Right, there's nothing to prevent the file from being deleted, so if you can avoid it you should. Most cases aren't as simple and writing out a state file is acceptable, but I see where your prof is coming from and agree.

Ok, so you know that the contents of MESSAGE will be expanded into the script as it is written to stdin when at is executed. You also know that your list of users is known when you invoke at, and that you could cause that list to be expanded into your script. So, is there another looping construct that you might be able to use in place of the while that would allow you to loop through the list of names?
Sure, the for loop but I could not get it to work either. i.e.

Code:
echo "\nEnter time: "
read TIME
echo "\nEnter message: "
read MESSAGE
echo "\nEnter user(s): "
read LOGNAMES
at -k $TIME << EOF
for NAME in $LOGNAMES
     do
     echo $MESSAGE | write $NAME$
     DONE
EOF

This code was sending me an email telling me how to use the write command. I am at my wits end here and about to give up. Of course I won't but it is getting old and getting frustrating. Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with speeding up my working script to take less time - how to use more CPU usage for a script

Hello experts, we have input files with 700K lines each (one generated for every hour). and we need to convert them as below and move them to another directory once. Sample INPUT:- # cat test1 1559205600000,8474,NormalizedPortInfo,PctDiscards,0.0,Interface,BG-CTA-AX1.test.com,Vl111... (7 Replies)
Discussion started by: prvnrk
7 Replies

2. UNIX for Beginners Questions & Answers

Why is this script not working?

for file in $(find /home/p611568/*.rpt -mtime -2 | grep -v ftplog) do awk '$1 == "XifPages," {PAGE = $5} $1 == "XifEndOfDocuments," {LINE = $5} index($0,"Value") && index($1,"Info") {sevGTI = 1} END {if (sevGTI) printf "%7s%10s%s",PAGE,LINE ... (4 Replies)
Discussion started by: bcarosi
4 Replies

3. Shell Programming and Scripting

Script not working

Hi i have write the one scripts and the scripts is error. The scripts purpose select one directory to check the file is there or not. i will give the two format of file to search the mention the path one file is there to select the file one copy the another location.please check the my script give... (1 Reply)
Discussion started by: rajivgandhi
1 Replies

4. Shell Programming and Scripting

expect script inside shell script not working.

Shell Scipt: temp.sh su - <$username> expect pass.exp Expect script: pass.exp #!/usr/bin/expect -f # Login ####################### expect "Password: " send "<$password>\r" it comes up with Password: but doesnt take password passed throguh file. (2 Replies)
Discussion started by: bhavesh.sapra
2 Replies

5. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

6. Shell Programming and Scripting

Script is not working from cron while working manually

Hello, I am facing a very strange problem when I run my script manuallu ./Fetchcode which is using to connect with MKS integrity from linux end it workks fine but when I run it from cron it doesn't work.Can someone help me 1) How could I check my script when it is running from cron like... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

7. UNIX for Dummies Questions & Answers

script not working

hi guys im new to unix and what to get this script working the scripts purpose its purpose is to move files i copy it from a HP UX pdf just for practice but when i execute it comes up wit this error command not found on the line if plz help me and thank in advance to those who do ps im... (3 Replies)
Discussion started by: ShinTec
3 Replies

8. Shell Programming and Scripting

Perl script 'system' linking to local shell script not working

Trying to figure out why this works: printpwd.pl #!/usr/bin/perl use CGI::Carp qw( fatalsToBrowser ); print "Content-type: text/html\n\n"; $A = system("pwd"); $A = `pwd`; print "$A\n"; ^^actually that works/breaks if that makes any sense.. i get the working directory twice but when... (5 Replies)
Discussion started by: phpfreak
5 Replies

9. Shell Programming and Scripting

Script not working..."sort" not working properly....

Hello all, I have a file - 12.txt cat 12.txt =============================================== Number of executions = 2 Total execution time (sec.ms) = 0.009883 Number of executions = 8 Total execution time (sec.ms) = 0.001270 Number of... (23 Replies)
Discussion started by: Rahulpict
23 Replies

10. Shell Programming and Scripting

Script not working.

Hi, I am a DBA, worked on Windows platforms for past 6 years, and now shifted in environment where HP UX is OS environment. I have task to complete which involves Unix script to be prepared. This script should FTP the file to the destination server and if this FTP fails, then it should... (5 Replies)
Discussion started by: Nishchal_Nagre
5 Replies
Login or Register to Ask a Question