Sponsored Content
Full Discussion: at reminder script
Homework and Emergencies Homework & Coursework Questions at reminder script Post 302561633 by Corona688 on Tuesday 4th of October 2011 04:23:26 PM
Old 10-04-2011
"$" variables are likely being substituted before the script is run, so $inputline never changes. You have to escape it with \.

This !! business is strange as well. On my system, that tells it to end the here document on 'man write', since that's the command I ran last.

Code:
at -k $TIME <<EOF
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
EOF

That's a useless use of cat, by the way. Any command can be redirected to file, not just cat -- so leave off the cat and send your last cut into a file, cut -c12-20 > ~/tmp

That's also a useless use of a temp file. You can just feed cut's output directly into the while loop with no intervening file: a | b | c | while read LINE ; do stuff ; done

You never did redirect write's stderr to >dev/null like write ... 2>/dev/null to throw away the messages.

Show me what your who output looks like, and I'll find a more elegant way to get what you want than cut | grep | cut | cat, too.
 

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
CUT-DIFF(1)							  Cutter's manual						       CUT-DIFF(1)

NAME
cut-diff - show difference between 2 files with color SYNOPSIS
cut-diff [option ...] file1 file2 DESCRIPTION
cut-diff is a diff command that uses diff feature in Cutter. It shows difference with color. It's recommended that you use a normal diff(1) when you want to use with patch(1) or you don't need color. OPTIONS
--version cut-diff shows its own version and exits. -c [yes|true|no|false|auto], --color=[yes|true|no|false|auto] If 'yes' or 'true' is specified, cut-diff uses colorized output by escape sequence. If 'no' or 'false' is specified, cut-diff never use colorized output. If 'auto' or the option is omitted, cut-diff uses colorized output if available. The default is auto. -u, --unified cut-diff uses unified diff format. --context-lines=LINES Shows diff context around LINES. All lines are shown by default. When unified diff format is used, 3 lines are shown by default. --label=LABEL, -L=LABEL Uses LABEL as a header label. The first--label option value is used as file1's label and the second --label option value is used asfile2's label. Labels are the same as file names by default. EXIT STATUS
The exit status is 0 for success, non-0 otherwise. TODO: 0 for non-difference, 1 for difference and non-0 for errors. EXAMPLE
In the following example, cut-diff shows difference between file1 and file2: % cut-diff file1 file2 In the following example, cut-diff shows difference between file1 and file2 with unified diff format: % cut-diff -u file1 file2 SEE ALSO
diff(1) Cutter February 2011 CUT-DIFF(1)
All times are GMT -4. The time now is 04:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy