manipulate file descriptor tables from shell

manipulate file descriptor tables from shell

Post by Johnny Diligent » Wed, 27 Jun 2001 02:30:41



does anyone know how to manipulate file descriptors from the shell given
a process of terminal.

what i want to is ssh into a remote host via one or more intermediate
nodes. once i have a secure connection between the two endpoints i want
to redirect stdout of a certain local program into stdin of the local
ssh client. then my data would end up on stdout of my remote terminal
which i want to redirect to a file instead of my local monitor.

i would need three logins total. one remote ssh login for the secure
channel. another remote ssh login to move remote file descriptors around
(remote control), and a third local login to move file descriptors
around (local control).

can anyone help before i start trying to write code for this?

jd

 
 
 

manipulate file descriptor tables from shell

Post by Barry Margoli » Wed, 27 Jun 2001 03:04:07




Quote:>does anyone know how to manipulate file descriptors from the shell given
>a process of terminal.

>what i want to is ssh into a remote host via one or more intermediate
>nodes. once i have a secure connection between the two endpoints i want
>to redirect stdout of a certain local program into stdin of the local
>ssh client. then my data would end up on stdout of my remote terminal
>which i want to redirect to a file instead of my local monitor.

>i would need three logins total. one remote ssh login for the secure
>channel. another remote ssh login to move remote file descriptors around
>(remote control), and a third local login to move file descriptors
>around (local control).

>can anyone help before i start trying to write code for this?

I don't know any way to manipulate descriptors of an existing process like
you suggest, either from the shell or a program (a process can manipulate
its *own* descriptors using dup2(), but not the descriptors of another
process).  Why don't you just use ordinary pipes:

local-program | ssh remotehost 'cat > remote-file'

If you need to go through intermediate hosts, it could be:

local-program | ssh remote1 ssh remote2 'cat > remote-file'

It might be necessary to escape the quotes to make sure they're passed on
properly to the second ssh; I haven't tested it, so you'll need to play
with it to get it right.

--

Genuity, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

manipulate file descriptor tables from shell

Post by James T. Denni » Fri, 29 Jun 2001 14:27:38





>>does anyone know how to manipulate file descriptors from the shell given
>>a process of terminal.
>>what i want to is ssh into a remote host via one or more intermediate
>>nodes. once i have a secure connection between the two endpoints i want
>>to redirect stdout of a certain local program into stdin of the local
>>ssh client. then my data would end up on stdout of my remote terminal
>>which i want to redirect to a file instead of my local monitor.
>>i would need three logins total. one remote ssh login for the secure
>>channel. another remote ssh login to move remote file descriptors around
>>(remote control), and a third local login to move file descriptors
>>around (local control).
>>can anyone help before i start trying to write code for this?
> I don't know any way to manipulate descriptors of an existing process like
> you suggest, either from the shell or a program (a process can manipulate
> its *own* descriptors using dup2(), but not the descriptors of another
> process).  Why don't you just use ordinary pipes:
> local-program | ssh remotehost 'cat > remote-file'
> If you need to go through intermediate hosts, it could be:
> local-program | ssh remote1 ssh remote2 'cat > remote-file'
> It might be necessary to escape the quotes to make sure they're passed on
> properly to the second ssh; I haven't tested it, so you'll need to play
> with it to get it right.

        I've seen a trick where the intermediate node is
        configured to run an ssh port forwarding command
        to the inside box.  It was a bit confusing so I haven't
        tried to figure it out and duplicate it, but it was
        someting using the -L and -R (choosing local and remote
        ports) and possibly the -N options.

        Basically it can create a tcp tunnel through a proxy
        server and out/in to a machine on a non-routable address
        on the other side.

        Sorry I don't have a simple example to provide.  I also
        can't say whether this would meet the original poster's
        needs.

 
 
 

1. lilo problem: descriptor table (map file) corrupted!!

Dear lilo-users,

I have been fooling around with lilo a little bit. I encountered
a problem which I do not understand. I seek your
help.

I have a lilo.conf file in /etc. I use this file to put lilo
on floppy disk (boot=/dev/fd0). I have two more config files
(pardon me for such perversion!!). One called
lilo.conf.hda4, which I use to install lilo on the boot sector of
/dev/hda4. The last config file named lilo.conf.temp is just a
copy of the lilo.conf (i.e. I use it to install lilo on
/dev/fd0) but I use different map files for each of the above
config files (using "map = map_filename"). This should allow me
not to corrupt the map files corresponding to other
configurations.
eg.

I ran

lilo -C lilo.conf.hda4

lilo was installed on the boot sector of /dev/hda4 and its own
map file is created (ie. the map files of the other
configurations are not touched, am I right in my beliefs?)

But although I can boot off my hard disk (/dev/hda4 being active
partition), I can not boot off now from /dev/fd0. The prompt
is

LIL-

The - sign is supposed to signify that the descriptor table is
corrupt (checksum error!). But I could boot off using the same
floppy disk before I reinstalled lilo on /dev/hda4 and during
this reinstallation I have *neither touched map file for the
lilo configuration of the /dev/fd0 nor have I moved/recompiled
any of the kernels nor have I formatted any msdos drives*

Why does the descriptor table get corrupted? Any ideas??

Thanks in advance!

--Sachin

2. Linux Real-Time I/O

3. file descriptor table

4. implementation of poll()

5. manipulating routing tables for an LRP beginner

6. Questions from a potential convert . . .

7. Manipulating routing table

8. Dual Boot System

9. manipulate routing table

10. "Bad file descriptor" with Bash; how to designate descriptors?

11. file descriptor swapping in bourne shell

12. Korn shell and file descriptors

13. shell variants's open file descriptors