public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-user] Restart network interfaces over SSH
@ 2006-07-29  9:20 Todor Pirov
  2006-07-29  9:25 ` Raymond Lewis Rebbeck
  2006-07-29  9:40 ` Uwe Thiem
  0 siblings, 2 replies; 5+ messages in thread
From: Todor Pirov @ 2006-07-29  9:20 UTC (permalink / raw
  To: gentoo-user

Hello,
I have the following script which exchanges the IPs of two network adapters:

[code]
#!/bin/bash

/usr/bin/cp /etc/conf.d/net-2 /etc/conf.d/net;
/etc/init.d/net.eth1 stop;
/etc/init.d/net.eth0 restart;
/etc/init.d/net.eth1 start
[/code]

and a similar one with "/usr/bin/cp /etc/conf.d/net-1 /etc/conf.d/net;" in it 
to restore the original situation. In net-1 and net-2 config files the IPs of 
eth0 and eth1 are substituted.
The problem is that when I run the script from eth1 via SSH it stops executing 
when the interface stops. If it is ran from eth0 it executes normally.
Is there a way to tell bash not to stop executing commands if connection is 
broken or some more convenient gentoo-style way to exchange the IPs from SSH.
TIA

Todor
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-user] Restart network interfaces over SSH
  2006-07-29  9:20 [gentoo-user] Restart network interfaces over SSH Todor Pirov
@ 2006-07-29  9:25 ` Raymond Lewis Rebbeck
  2006-07-29  9:43   ` Todor Pirov
  2006-07-29  9:46   ` Alexander Skwar
  2006-07-29  9:40 ` Uwe Thiem
  1 sibling, 2 replies; 5+ messages in thread
From: Raymond Lewis Rebbeck @ 2006-07-29  9:25 UTC (permalink / raw
  To: gentoo-user

On Saturday, 29 July 2006 18:50, Todor Pirov wrote:
> Hello,
> I have the following script which exchanges the IPs of two network
> adapters:
>
> [code]
> #!/bin/bash
>
> /usr/bin/cp /etc/conf.d/net-2 /etc/conf.d/net;
> /etc/init.d/net.eth1 stop;
> /etc/init.d/net.eth0 restart;
> /etc/init.d/net.eth1 start
> [/code]
>
> and a similar one with "/usr/bin/cp /etc/conf.d/net-1 /etc/conf.d/net;" in
> it to restore the original situation. In net-1 and net-2 config files the
> IPs of eth0 and eth1 are substituted.
> The problem is that when I run the script from eth1 via SSH it stops
> executing when the interface stops. If it is ran from eth0 it executes
> normally. Is there a way to tell bash not to stop executing commands if
> connection is broken or some more convenient gentoo-style way to exchange
> the IPs from SSH. TIA
>
> Todor

How about running the script in a screen session?

-- 
Raymond Lewis Rebbeck
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-user] Restart network interfaces over SSH
  2006-07-29  9:20 [gentoo-user] Restart network interfaces over SSH Todor Pirov
  2006-07-29  9:25 ` Raymond Lewis Rebbeck
@ 2006-07-29  9:40 ` Uwe Thiem
  1 sibling, 0 replies; 5+ messages in thread
From: Uwe Thiem @ 2006-07-29  9:40 UTC (permalink / raw
  To: gentoo-user

On 29 July 2006 10:20, Todor Pirov wrote:
> Hello,
> I have the following script which exchanges the IPs of two network
> adapters:
>
> [code]
> #!/bin/bash
>
> /usr/bin/cp /etc/conf.d/net-2 /etc/conf.d/net;
> /etc/init.d/net.eth1 stop;
> /etc/init.d/net.eth0 restart;
> /etc/init.d/net.eth1 start
> [/code]
>
> and a similar one with "/usr/bin/cp /etc/conf.d/net-1 /etc/conf.d/net;" in
> it to restore the original situation. In net-1 and net-2 config files the
> IPs of eth0 and eth1 are substituted.
> The problem is that when I run the script from eth1 via SSH it stops
> executing when the interface stops. If it is ran from eth0 it executes
> normally. Is there a way to tell bash not to stop executing commands if
> connection is broken or some more convenient gentoo-style way to exchange
> the IPs from SSH. TIA
nohup your_script &

The ssh connection will still be interrupted but the script will finish.

Uwe

-- 
Mark Twain: I rather decline two drinks than a German adjective.
http://www.SysEx.com.na
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-user] Restart network interfaces over SSH
  2006-07-29  9:25 ` Raymond Lewis Rebbeck
@ 2006-07-29  9:43   ` Todor Pirov
  2006-07-29  9:46   ` Alexander Skwar
  1 sibling, 0 replies; 5+ messages in thread
From: Todor Pirov @ 2006-07-29  9:43 UTC (permalink / raw
  To: gentoo-user

On Saturday 29 July 2006 12:25, Raymond Lewis Rebbeck wrote:
> How about running the script in a screen session?

Yes, "screen -d" is a solution. Thanks for the tip.

Todor
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [gentoo-user] Restart network interfaces over SSH
  2006-07-29  9:25 ` Raymond Lewis Rebbeck
  2006-07-29  9:43   ` Todor Pirov
@ 2006-07-29  9:46   ` Alexander Skwar
  1 sibling, 0 replies; 5+ messages in thread
From: Alexander Skwar @ 2006-07-29  9:46 UTC (permalink / raw
  To: gentoo-user

Raymond Lewis Rebbeck schrieb:

> How about running the script in a screen session?

Another one:
Put that script in a "script file" (like /tmp/script). Then setup
an "at" job, which will execute this:

	at now + 1minute < /tmp/script

And finally, it might be enough to make the shell ignore the HUP
(Hang Up) signal, by using nohup:

	nohup sh /tmp/script

Alexander Skwar
-- 
"It runs like _\bx, where _\bx is something unsavory"
		-- Prof. Romas Aleliunas, CS 435
-- 
gentoo-user@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-07-29  9:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-29  9:20 [gentoo-user] Restart network interfaces over SSH Todor Pirov
2006-07-29  9:25 ` Raymond Lewis Rebbeck
2006-07-29  9:43   ` Todor Pirov
2006-07-29  9:46   ` Alexander Skwar
2006-07-29  9:40 ` Uwe Thiem

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox