• auto interactive jobs

    From Bitfox@21:1/5 to All on Fri Nov 22 01:30:01 2024
    Hi

    I have a interactive command like the following,

    $ ./filen
    / > upload upt-snappy /
    Uploading upt-snappy [========================================] 100% |
    ETA: 0s | 1.4 KiB / 1.32 KiB
    / >


    the command "filen" will open a interactive shell, and in this shell to upload/download files.

    How can I write a script for this case to upload file automatically?

    Thanks.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From eben@gmx.us@21:1/5 to Bitfox on Fri Nov 22 01:30:01 2024
    On 11/21/24 19:24, Bitfox wrote:
    Hi

    I have a interactive command like the following,

    $ ./filen
    / > upload upt-snappy /
    Uploading upt-snappy [========================================] 100% | ETA: 0s | 1.4 KiB / 1.32 KiB
    / >


    the command "filen" will open a interactive shell, and in this shell to upload/download files.

    How can I write a script for this case to upload file automatically?

    Can you do something like
    echo "upload upt-snappy p" | ./filen
    ?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bitfox@21:1/5 to eben@gmx.us on Fri Nov 22 01:40:01 2024
    On 2024-11-22 08:28, eben@gmx.us wrote:
    On 11/21/24 19:24, Bitfox wrote:
    Hi

    I have a interactive command like the following,

    $ ./filen
    / > upload upt-snappy /
    Uploading upt-snappy [========================================] 100% |
    ETA:
    0s | 1.4 KiB / 1.32 KiB
    / >


    the command "filen" will open a interactive shell, and in this shell
    to
    upload/download files.

    How can I write a script for this case to upload file automatically?

    Can you do something like
    echo "upload upt-snappy p" | ./filen
    ?

    That seems impossible.

    $ echo "upload tmp" |./filen
    upload tmp
    Error trying to prompt for user input: readline was closed. (maybe
    you're in an environment without stdin, like a Docker container)
    Error [ERR_USE_AFTER_CLOSE]: readline was closed

    Regards

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Christensen@21:1/5 to Bitfox on Fri Nov 22 01:40:01 2024
    On 11/21/24 16:24, Bitfox wrote:
    Hi

    I have a interactive command like the following,

    $ ./filen
    / > upload upt-snappy /
    Uploading upt-snappy [========================================] 100% |
    ETA: 0s | 1.4 KiB / 1.32 KiB
    / >


    the command "filen" will open a interactive shell, and in this shell to upload/download files.

    How can I write a script for this case to upload file automatically?

    Thanks.


    The canonical old-school solution for automating command line programs
    is expect(1):

    https://man7.org/linux/man-pages/man1/expect.1.html


    Some scripting languages have the ability to achieve the same effect. I
    prefer Perl, so:

    https://metacpan.org/pod/Expect


    David

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Wooledge@21:1/5 to Bitfox on Fri Nov 22 01:50:02 2024
    On Fri, Nov 22, 2024 at 08:37:03 +0800, Bitfox wrote:
    $ echo "upload tmp" |./filen
    upload tmp
    Error trying to prompt for user input: readline was closed. (maybe you're in an environment without stdin, like a Docker container)
    Error [ERR_USE_AFTER_CLOSE]: readline was closed

    I would start by reading the documentation for this "filen" thing.
    Does it have any kind of batch or noninteractive mode?

    If it doesn't, and if the simple "write commands to stdin" didn't work
    (as shown above), then you're looking at Expect. David linked to one
    man page for it. There's a *lot* more out there. Here's a wiki page
    that has lots more links:
    <https://wiki.tcl-lang.org/page/Expect>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Ritter@21:1/5 to eben@gmx.us on Fri Nov 22 01:50:02 2024
    eben@gmx.us wrote:
    On 11/21/24 19:24, Bitfox wrote:
    Hi

    I have a interactive command like the following,

    $ ./filen
    / > upload upt-snappy /
    Uploading upt-snappy [========================================] 100% | ETA: 0s | 1.4 KiB / 1.32 KiB
    / >


    the command "filen" will open a interactive shell, and in this shell to upload/download files.

    How can I write a script for this case to upload file automatically?

    Can you do something like
    echo "upload upt-snappy p" | ./filen


    If that doesn't work, you may be able to script an interaction
    with expect

    Description: Automates interactive applications
    Expect is a tool for automating interactive applications according to a script.
    Following the script, Expect knows what can be expected from a program and what
    the correct response should be. Expect is also useful for testing these same
    applications. And by adding Tk, you can also wrap interactive applications in
    X11 GUIs. An interpreted language provides branching and high-level control
    structures to direct the dialogue. In addition, the user can take control and
    interact directly when desired, afterward returning control to the script.
    .
    This package contains the expect binary and several Expect based scripts.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From eben@gmx.us@21:1/5 to Bitfox on Fri Nov 22 02:00:01 2024
    On 11/21/24 19:37, Bitfox wrote:
    On 2024-11-22 08:28, eben@gmx.us wrote:
    On 11/21/24 19:24, Bitfox wrote:
    Hi

    I have a interactive command like the following,

    $ ./filen
    / > upload upt-snappy /
    Uploading upt-snappy [========================================] 100% | ETA: >>> 0s | 1.4 KiB / 1.32 KiB
    / >


    the command "filen" will open a interactive shell, and in this shell to
    upload/download files.

    How can I write a script for this case to upload file automatically?

    Can you do something like
    echo "upload upt-snappy p" | ./filen
    ?

    That seems impossible.

    $ echo "upload tmp" |./filen
    upload tmp
    Error trying to prompt for user input: readline was closed. (maybe you're in an environment without stdin, like a Docker container)
    Error [ERR_USE_AFTER_CLOSE]: readline was closed

    I'm not familiar with filen. Does it have an option like "read input from
    file X"? Or heck use expect, as others have suggested.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)