• UUOE (Was: echoing the last command inside bash function)

    From Kenny McCormack@21:1/5 to [email protected] on Thu Jun 30 15:40:40 2022
    XPost: alt.os.linux

    In article <t9kemj$1u4fr$[email protected]>,
    Lew Pitcher <[email protected]> wrote:
    ...
    Try
    echo "tree dir" | script -a commands-output

    At least in principle: script -a commands-output <<< "tree dir"
    But I actually don't know if script reads from stdin like this anyway.

    So:

    script -ac "tree dir" commands-output

    Note: I do endorse using script for this. A useful command that many don't know about.

    --
    To most Christians, the Bible is like a software license. Nobody
    actually reads it. They just scroll to the bottom and click "I agree."

    - author unknown -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Lew Pitcher@21:1/5 to Kenny McCormack on Thu Jun 30 15:59:43 2022
    XPost: alt.os.linux

    On Thu, 30 Jun 2022 15:40:40 +0000, Kenny McCormack wrote:

    In article <t9kemj$1u4fr$[email protected]>,
    Lew Pitcher <[email protected]> wrote:
    ...
    Try
    echo "tree dir" | script -a commands-output

    At least in principle: script -a commands-output <<< "tree dir"
    But I actually don't know if script reads from stdin like this anyway.

    So:

    script -ac "tree dir" commands-output

    Nope. The OP "... would have liked to have the reference command,
    and then everything else." script -c does /not/ write the command
    into the typescript file.

    11:53 $ cat tree_ac.txt
    cat: tree_ac.txt: No such file or directory

    11:54 $ script -ac "tree tmp" tree_ac.txt
    Script started, file is tree_ac.txt
    tmp
    |-- a.out
    |-- tst
    `-- tst.c

    0 directories, 3 files
    Script done, file is tree_ac.txt

    11:54 $ cat tree_ac.txt
    Script started on Thu 30 Jun 2022 11:54:09 AM EDT
    tmp
    |-- a.out
    |-- tst
    `-- tst.c

    0 directories, 3 files

    Script done on Thu 30 Jun 2022 11:54:09 AM EDT
    11:54 $

    But
    echo "command" | script
    /does/ write the command into the typescript file

    11:56 $ cat tree_a.txt
    cat: tree_a.txt: No such file or directory

    11:56 $ echo "tree tmp" | script -a tree_a.txt
    Script started, file is tree_a.txt
    tree tmp
    11:56 $ tree tmp
    tmp
    |-- a.out
    |-- tst
    `-- tst.c

    0 directories, 3 files
    11:56 $ exit
    Script done, file is tree_a.txt

    11:56 $ cat tree_a.txt
    Script started on Thu 30 Jun 2022 11:56:30 AM EDT
    tree tmp
    11:56 $ tree tmp
    tmp
    |-- a.out
    |-- tst
    `-- tst.c

    0 directories, 3 files

    11:56 $

    Script done on Thu 30 Jun 2022 11:56:30 AM EDT
    11:56 $

    Note: I do endorse using script for this. A useful command that many don't know about.




    --
    Lew Pitcher
    "In Skills, We Trust"

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