in reply to (tye)Re2: Writing to descriptor 3
in thread Writing to descriptor 3

Alright. I get it.
Actually, I'm lying. I understand what you mean, but I guess I'm at a loss on how to make it do what I want.

When checkpassword is run, it checks fd 3 (Which, I believe, it supposed to be somehow already open - since the first line is a read()) and then returns an exit status depending on its result.
My script is the front-end to checkpassword, I need to open fd 3, write the username/pw pair to fd 3, and then run 'checkpassword' and watch its exit stat.

Any clues?

JP
-- Alexander Widdlemouse undid his bellybutton and his bum dropped off --

  • Comment on (JP)Re: (tye)Re2: Writing to descriptor 3

Replies are listed 'Best First'.
(tye)Re3: Writing to descriptor 3
by tye (Sage) on Mar 06, 2001 at 22:35 UTC

    Ah, the program requires you to arrange for it to be able to read from FD 3... hmm, I think that is probably a bad design on their part, but...

    I don't have time to write a solution at the moment. I guess you are supposed to create a pipe(), fork(), have the child close FD 3 and then use dup2() to make FD 3 the read end of the pipe, and finally exec() 'checkpassword'.

    You should be able to do this in Perl, but it may be a little tricky. [I don't think Perl gives the script writer full access to dup2() but you can still fake Perl into closing FD 3 and then just dup() the read end of the pipe with open(ANY,"<&READER")]

    Note also that to get the program to read from FD 3 does not require that you be writing to FD 3 (in case their documentation needs to be updated).

            - tye (but my friends call me "Tye")