|
OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below. |
|
Thread Tools | Display Modes |
|
|||
How do I run a shell command in a while loop?
Hi,
I am running an IRC client in OpenBSD and I choose sic because with such short amount of lines it seems very audit-able for security as opposed to larger clients such as irssi. I usually perform: Code:
sic -h irc.freenode.net 2>&1 | tee -a irc.log I'm trying to handle reconnects by running it in a while loop in the shell process and cat the initial commands into sic's stdin. I would think to approach this by using a fifo (using the mkfifo(1) command) to redirect sic's stdin, but I'm not sure if there's a more elegant way to reconnect on ping timeouts, kills, servers going down, and just disconnects in general. How do you suggest I go about doing this? |
|
|||
Well, I'm sure you have an understanding of general IRC even if you don't use it? In any case, sic is a very simple IRC client (that's what sic is an acronym for) that outputs the actualy IRC interaction to the shell directly, i.e.:
Code:
[~] $ sic -h irc.freenode.net 2>&1 | tee -a irc.log zelazny.freenode.net: 12/05/11 14:45 >< NOTICE (*): *** Looking up your hostname... zelazny.freenode.net: 12/05/11 14:45 >< NOTICE (*): *** Checking Ident zelazny.freenode.net: 12/05/11 14:45 >< NOTICE (*): *** Found your hostname ^C [~] $ Code:
[~] $ sic -h irc.freenode.net 2>&1 | tee -a irc.log zelazny.freenode.net: 12/05/11 14:45 >< NOTICE (*): *** Looking up your hostname... zelazny.freenode.net: 12/05/11 14:45 >< NOTICE (*): *** Checking Ident zelazny.freenode.net: 12/05/11 14:45 >< NOTICE (*): *** Found your hostname sic shutting down: parse timeout [~] $ |
|
|||
Quote:
From your description, it appears under certain conditions, sic simply terminates, & this is the behavior you wish to change -- as you wish to execution to not terminate. Creating a wrapper around sic as it currently is will not change its termination logic. It appears what you want to do is change the behavior of sic itself. You will need to study the source code to see where the execution logic needs to be changed, or find a forum/mailing list which focuses on the application itself. Now, if you don't care if a different instance is started, then I would play further with a simple wrapper as jggimi originally suggested. |
|
|||
If the sic is reading from stdin that you cat'ed with initial commands sic should see an EOF (end of file). When it sees that I would expect it to exit. I would not expect it to switch from reading the cat'ed or piped input to the keyboard.
> I'm trying to handle reconnects by running it in a while loop in > the shell process and cat the initial commands into sic's stdin. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Running a command as a different user w/o starting the login shell | Carpetsmoker | General software and network | 4 | 1st July 2011 10:33 PM |
DHCP client allows shell command injection | J65nko | News | 0 | 7th April 2011 01:09 AM |
Full disk encryption with Loop-AES | deviant085 | OpenBSD Security | 9 | 23rd November 2009 12:51 AM |
Reboot loop on 7.0 upgraded to 7.1 | EricM | FreeBSD Installation and Upgrading | 3 | 25th March 2009 04:25 AM |
ibm eserver x225 - 7.0 installation when btx halted / endless loop | underlig | FreeBSD Installation and Upgrading | 3 | 3rd August 2008 02:19 PM |