Find the answer to your Linux question:
Results 1 to 9 of 9
Hello, I have developed a shell script which will invoke a binary as below: ./binary-name < input-file.txt The values prompted by the binary are sent from the input-file.txt. It executes ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2005
    Posts
    8

    Need help on sending password to a binary using I/O redirection


    Hello,

    I have developed a shell script which will invoke a binary as below:

    ./binary-name < input-file.txt

    The values prompted by the binary are sent from the input-file.txt.
    It executes fine and the binary gives the expected outcome.

    I have another binary and use the same format to pass values using I/O redirection.This binary prompts for a password and the password is specified in the input-file.txt.When it prompts for password,the binary execution hangs out and it quits the shell script itself.

    Could anyone help me out in resolving the problem ?

    Note:
    I tried using "Expect" scripts.The same worked fine.But I don't want to use "Expect" scripts.

    Iam using Red Hat AS 3.0

    Thanks,
    Nithya

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    I'm sure we could if you'd post the source.

  3. #3
    Just Joined!
    Join Date
    Jun 2005
    Posts
    8
    Hi lakerdonald,

    I cannot post the source of the binary.

    Coz i got it from my client and i donot have access to view the source.

    Thanks for the reply.

    Please help me on this.

    Thanks,
    Nithya

  4. #4
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575

    Re: Need help on sending password to a binary using I/O redirection

    Quote Originally Posted by Nithya
    I have another binary and use the same format to pass values using I/O redirection.This binary prompts for a password and the password is specified in the input-file.txt.When it prompts for password,the binary execution hangs out and it quits the shell script itself.
    So let me see if I understand this:
    1) If you execute the binary from the command line and you
    type the password it works correctly, right ?
    2) What happens if you type at the command line ./binary-name < input-file.txt
    where binary-name refers to the one which doesn't work properly ?

  5. #5
    Just Joined!
    Join Date
    Jun 2005
    Posts
    8
    Hi,

    1.When i execute the binary as "./binary-name" and key in the values manually through keyboard,the password is accepted (Note:the password is accepted as a hidden value at the prompt) and execution of the binary completes as expected.There is no error with the binary.

    2.I would like to maintain the values that are keyed in manually in a text file.I am redirecting the text file as input to the binary during execution as "./binary-name < input-file.txt".

    So that it can fetch the values line by line from the text file.It fetches all other values prior to the password value from the file and executes well.
    When the binary prompts for the password,it could not fetch the password from the text file and the execution hangs around there.

    My query : "Is there any way to pass on the password from the text file?"
    or else "Is it the issue to be handled inside the binary?"

    Note:The binary used in the description of step 1 and 2 are the same.
    Thanks for the help

  6. #6
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    When the binary prompts for the password,it could not fetch the password from the text file and the execution hangs around there.
    Does it prompt you for a password before it hangs ? Even if it doesn't
    try typing the password when it seems to be hanged and see what
    happens.But to be honest I doubt there is a solution to your probelem.

  7. #7
    Just Joined!
    Join Date
    Jun 2005
    Posts
    8
    Hi,

    Thanks for the immediate response.

    1.Ya, the binary prompts for the password.After some 2 seconds ,it exits and returns to the command prompt automatically.But the binary has some more to execute after the password entry.

    2.Even if i try to enter the password manually, the same situation as the above repeats.

    Any solution in this regard would be of great help !

    Thanks,
    Nithya

  8. #8
    scm
    scm is offline
    Linux Engineer
    Join Date
    Feb 2005
    Posts
    1,044
    A lot of programs that require passwords go to considerable lengths to ensure that their stdin is connected to a keyboard, precisely to prevent the insecure running such as you're attempting.

  9. #9
    Linux Enthusiast
    Join Date
    Jan 2005
    Posts
    575
    Yes , but what I find a bit strange is that the password cannot be
    entered even from the keyboard.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •