Discussion:
[Ipmitool-devel] Running serial-over-lan noninteractively
Petr Janecek
2014-02-20 13:06:28 UTC
Permalink
Hello,
I'm trying to do something as simple as capturing the output of
serial console over the lan to a file. Have I missed some obvious
way of doing that? I'm trying to use something like

nohup ipmitool -I lanplus -H ... -U ... -f ... sol activate > sol.log &

but the ipmitool is not happy about having /dev/null as an input: ioctls
don't work and it exits immediately as the input is empty.

The patch enables the above mentioned usage and should have no effect
on interactive use. Would it be better to enable the changes in
ipmi_sol_red_pill() only by some command line option, as it changes the
behavior on the end of input?


diff --git a/lib/ipmi_sol.c b/lib/ipmi_sol.c
index 4b829fc..29dc010 100644
--- a/lib/ipmi_sol.c
+++ b/lib/ipmi_sol.c
@@ -1161,6 +1161,8 @@ void
enter_raw_mode(void)
{
struct termios tio;
+ if (!isatty(fileno(stdout)))
+ return;
if (tcgetattr(fileno(stdin), &tio) == -1) {
perror("tcgetattr");
return;
@@ -1541,6 +1543,7 @@ ipmi_sol_red_pill(struct ipmi_intf * intf, int instance)
int buffer_size = intf->session->sol_data.max_inbound_payload_size;
int keepAliveRet = 0;
int retrySol = 0;
+ int on_tty = 0;

/* Subtract SOL header from max_inbound_payload_size */
if (buffer_size > 4)
@@ -1556,12 +1559,14 @@ ipmi_sol_red_pill(struct ipmi_intf * intf, int instance)
gettimeofday(&_start_keepalive, 0);

enter_raw_mode();
+ on_tty = isatty(fileno(stdout));

while (! bShouldExit)
{
FD_ZERO(&read_fds);
FD_SET(0, &read_fds);
- FD_SET(intf->fd, &read_fds);
+ if (on_tty)
+ FD_SET(intf->fd, &read_fds);

if (!ipmi_oem_active(intf,"i82571spt"))
{
@@ -1860,8 +1865,9 @@ ipmi_sol_activate(struct ipmi_intf * intf, int looptest, int interval,
}
}

- printf("[SOL Session operational. Use %c? for help]\n",
- intf->session->sol_escape_char);
+ if (isatty(fileno(stdout)))
+ printf("[SOL Session operational. Use %c? for help]\n",
+ intf->session->sol_escape_char);

if(looptest == 1)
{


Thanks,

Petr Janecek

Loading...