Robs answer may be better for your specific situation, but to answer your
original question:

- "echo %ssh" will echo the pids of all child jobs whose command line starts
with 'ssh'
- "echo %1" will echo the pid of job 1 (check 'job control' if you need to).

- A command like 'fish -c "echo %self; exec ssh user@somewhere"' will start
a new shell that will echo it's own pid and then exec ssh (keeping the pid).

- I don't think there is an exact analogue to bash's $! that will expand
into the pid of the last background process, but I can't think of any
situation that can't be solved with one of the above solutions.

Jan


On Wed, Feb 23, 2011 at 16:19, Rob Farmer <rfar...@predatorlabs.net> wrote:

> On Wed, Feb 23, 2011 at 6:47 AM, David Frascone <d...@frascone.com> wrote:
> >
> > My office just started doing DMZ nonsense, so I have to bounce through an
> > intermediary host to grab a file, sort of like this:
> > ssh -f -N -q -L 2222:dmz_machine_ip:22 user@intermediary_machine_ip
> > scp -P 2222 transformers.avi user@localhost:.
> >
> > So, my question is:  How can I grab the PID of that first ssh process, so
> I
> > can kill it (and drop the tunnel) after the scp?
> >
>
> This doesn't answer your question for PIDs, but should solve the
> overall problem.
>
> Change your ssh command to
> ssh -f -q -L 2222:dmz_machine_ip:22 user@intermediary_machine_ip sleep 60
>
> This establishes the tunnel for a 60 second window then dies silently.
> However, if port 2222 is still in use at the end of 60 seconds, ssh
> keeps the tunnel open until you disconnect. So, there's no manual
> cleanup required.
>
> --
> Rob Farmer
>
>
> ------------------------------------------------------------------------------
> Free Software Download: Index, Search & Analyze Logs and other IT data in
> Real-Time with Splunk. Collect, index and harness all the fast moving IT
> data
> generated by your applications, servers and devices whether physical,
> virtual
> or in the cloud. Deliver compliance at lower cost and gain new business
> insights. http://p.sf.net/sfu/splunk-dev2dev
> _______________________________________________
> Fish-users mailing list
> Fish-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fish-users
>
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users

Reply via email to