"write" bash command
Hello, I'm trying to write a bash script program in the Linux command terminal that will write to a fellow user and then continue reading down the program. this is what i have (kind of explains the idea too):
#!/bin/sh clear echo "this is before the write command" write jcummins this message should go to jerry echo "the message didn't send and this string will not appear" echo "it appears it has stopped at the write command" please help me, THANK YOU! |
Well I cannot say I have used this command, but I did find the following:
Quote:
|
I had never heard of the write command until this thread. But I figure, since other interactive stuff occurs in scripts, then why not? Though it really doesn't appear to need a script to be used, as it's kind of a one-shot deal:
Code:
sasha@reactor: w Code:
Message from sasha@reactor on pts/0 at 23:44 ... Sasha |
THANK YOU! you are amazing!
|
When I add a loop the program should send the message, "Hello Jerry!!" 5 times to jerry's terminal(assuming he is logged on to the server). But I keep getting this error: Syntax error: end of file unexpected (expecting "done")
I have tried everything and searched everywhere to find a solution and nothing has worked any ideas? Thanks! ----------------------------------------------------------------------- #!/usr/bin/sh clear x=1 # this sets up the flag so we can have it send a limited amount while [ $x -le 5 ] do write jcummins << EFO >Hello Jerry!! >EFO x=$(( $x + 1 )) done |
If that is the EXACT code that is in your script, then the problem is likely those ">" characters.
If you copied the code from my above example, then you should know that I just did that right in my console; this makes bash print the > character on the next line when it is waiting for more input. Other than those > characters, I don't see a problem with your code (other than that you have not specified which tty or pty jerry might be logged into). Also, for the record, EFO is usually "EOF" which stands for "End Of File", though if you like to use "EFO" you can certainly continue doing so; as long as the EOF and EOF at the start and end, are the same, it will work. Sasha |
All times are GMT -5. The time now is 06:53 AM. |