LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 10-30-2006, 11:53 PM   #1
jon_k
Member
 
Registered: Jul 2003
Location: Fort Worth, Texas
Distribution: Mepis Linux 2004
Posts: 547

Rep: Reputation: 30
Use bash to interface with "write" command?


Hi,

I need to add some features to a bash script that will use the "write" command to a user. Write and wall make scripting difficult because you can't send message bodies as the commandline arguement.

Is there any way to push text down writes throat using bash and then automate CTRL - C? (Probably an ansi code on the end of the message)?

Anyone who has accomplished something similar can help.

Thanks.
 
Old 10-31-2006, 12:11 AM   #2
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 653

Rep: Reputation: 32
you mean something like :

[root@tigerente ~]# echo "TEST^D" | write chakkerz
write: chakkerz is logged in more than once; writing to pts/7
[root@tigerente ~]#

and on pts/7:
[chakkerz@tigerente ~]$
Message from root@tigerente.its.uq.edu.au on pts/6 at 16:09 ...
TEST^D
EOF

??
the CTRL+C you mention i assume you want to use to terminate the message, if that is correct, you really want to use CTRL+D which is an EOF character. To put that in your message you use CTRL+V then CTRL+D so that TEST^D is actually TEST^V^D

hope that helps
 
Old 10-31-2006, 12:14 AM   #3
chakkerz
Member
 
Registered: Dec 2002
Location: Brisbane, Australia
Distribution: RedHat (RHEL, FC, CentOS), openSuSE, Mac OS X
Posts: 653

Rep: Reputation: 32
oh one thing to mention, that means that your server (the one running the program) will go back to the prompt. but that will happen if you don't have the ctrl+d in there...
 
Old 10-31-2006, 04:48 AM   #4
jon_k
Member
 
Registered: Jul 2003
Location: Fort Worth, Texas
Distribution: Mepis Linux 2004
Posts: 547

Original Poster
Rep: Reputation: 30
That's it!

Yeah, the CTRL-D character is what I meant.

Seems either is irrelevant though, as echo itself seems to be appropriate for sending EOF.

Adding the control char in there just results in:
Message from root@prole on pts/6 at 04:46 ...
TEST^D
EOF

Echo does the job without the ^C or ^D

Thanks so much, I tried write jkelley < file without success, this, however, seems even better.

Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bash script: using "select" to show multi-word options? (like "option 1"/"o zidane_tribal Programming 6 03-21-2013 10:35 AM
How to write a bash script to replace all "KH" to "K" in file ABC??? cqmyg5 Slackware 4 07-24-2007 09:00 AM
Bash: "after" or "waitfor" command enemorales Programming 3 06-15-2005 12:04 AM
trying to write code for UNIX command "which" live_dont_exist Programming 11 03-15-2005 12:16 PM
From BASH, "Play <filename.wav" gives obsolete oss interface message ericcarlson Fedora 3 09-14-2004 06:20 AM


All times are GMT -5. The time now is 02:27 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration