Find the answer to your Linux question:
Results 1 to 3 of 3
I am using ssh to interface with a server using ksh. I am executing a shell script(call it script A) with ssh and script A runs and has to call ...
  1. #1
    Just Joined!
    Join Date
    Jun 2010
    Posts
    2

    Supplying input to a nested script

    I am using ssh to interface with a server using ksh. I am executing a shell script(call it script A) with ssh and script A runs and has to call a java script( script J). The problem is that I cannot modify script J. It takes standard prompt input from the user. Since I am using ssh, I cannot supply the input as a user would usually do. I need script A to supply the input. I would pass it as an argument to script J, but I cannot modify script J at all. I am very open to any suggestions. None of my techniques thus far are set in stone and I am willing to go about it anyway that will get it to work.

    Thanks in advance.

  2. #2
    Linux Newbie theNbomr's Avatar
    Join Date
    May 2007
    Location
    BC Canada
    Posts
    150
    You need to know a bit about how the scriptJ reads its input. If it is reading stdin, then it would be a simple matter of redirecting its input from a file or pipe:
    Code:
    echo "Horty Florty" | scriptJ
    or
    Code:
    #
    # file.dat contains data to input to scriptJ
    scriptJ < file.dat
    There is the tool 'expect' which can be scripted to look for prompts and then emit responses according to what it sees.
    man expect
    There are one or two other real hacks, but try these ones first.
    --- rod.
    Stuff happens. Then stays happened.

  3. #3
    Just Joined!
    Join Date
    Jun 2010
    Posts
    2

    Thanks

    The expect works for me. Thanks for your help.

Posting Permissions

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