[Discuss] Ideas for solving a remove backup quandary
Jeremy Kiffiak
jeremy at truesolutions.ca
Tue May 13 17:25:26 PDT 2008
On 13-May-08, at 4:06 PM, Steven Kurylo wrote:
> On Tue, May 13, 2008 at 4:02 PM, Jeremy Kiffiak <jeremy at truesolutions.ca
> > wrote:
>> Chris,
>>
>> Thanks again, that did the trick as far as setting up the tunnel.
>> Next
>> question:
>>
>> How do I get the tunnel to delete itself after the script has
>> completed
>> successfully (or even not completed successfully)?
>
> Save the pid and kill it at the end of the script.
>
> ssh -P 10022 -C -f -N -L
> 127.0.0.1:10033:192.168.10.150:22<username>@remotegw1
> ssh_pid=$!
> [... do stuff ...]
> kill $ssh_pid
Ok, I guess I answered that a little too quickly. It certainly looks
good but does not have the intended result. Instead I get:
- - - - - - - - - -
~/bin$bash -x backup.sh
+ echo 'Creating remote tunnel . . .'
Creating remote tunnel . . .
+ ssh -f -p 10022 -C -N <username>@<destination> -L localhost:
18128:10.10.8.128:22
+ ssh_pid=
+ echo 'Tunnel created successfully!'
Tunnel created successfully!
+ echo 'Starting backup process'
Starting backup process
+ echo 'File(s) backed up!'
File(s) backed up!
+ echo 'Cleaning up SSH tunnel'
Cleaning up SSH tunnel
+ kill
kill: usage: kill [-s sigspec | -n signum | -sigspec] pid |
jobspec ... or kill -l [sigspec]
+ echo 'SSH tunnel removed'
SSH tunnel removed
- - - - - - - - - -
Help? In case it matters I am using BASH 3.2.17 (on OS X 10.5.2 but
that shouldn't matter, should it?). I will double-check tomorrow on
my Ubuntu 8.04 box to verify whether or not this is an OS specific
problem. Or perhaps a BASH version problem?
Jeremy
More information about the Discuss
mailing list