Shell output to file - redirect?
  • EVX
  • Just looking around
    Posts: 14 from 2026/1/10
    I am having a bit of rookie trouble getting the shell output to a file.

    What I see in the documentation is:

    command > file /A

    This only generates an empty file. I have tried creating the file first. I have tried >> to append the file.

    In my instance, I want to direct the output of the command "chelp all" to a file so I can print it.

    Please let me know what I am missing.
  • »31.01.26 - 04:07
    Profile
  • Paladin of the Pegasos
    Paladin of the Pegasos
    Amigaharry2
    Posts: 1363 from 2010/1/6
    From: EU-Austria (Wien)
    Code:
    File redirection example:
    help >RAM:file.txt ;saves output to RAM:file.txt
    type RAM:file.txt >PRT: ;send file.txt to Printer
    help >PRT: ;send output directly to printer


    [ Editiert durch Amigaharry2 31.01.2026 - 08:02 ]
    Peg2, 3xPowerMac G5, 2xPowerbookG4, 2x MacMiniG4, Efika (again), A3000T and life is never boring.....
  • »31.01.26 - 07:02
    Profile
  • EVX
  • Just looking around
    Posts: 14 from 2026/1/10
    Odd, I still get an empty file when trying the code below.

    I am using the command "chelp all" and would like to have the output stored in a file for easy reference.

    TIA for any help!

    -E


    Quote:

    Amigaharry2 wrote:
    Code:
    File redirection example:
    help >RAM:file.txt ;saves output to RAM:file.txt
    type RAM:file.txt >PRT: ;send file.txt to Printer
    help >PRT: ;send output directly to printer


    [ Editiert durch Amigaharry2 31.01.2026 - 08:02 ]
  • »31.01.26 - 16:19
    Profile
  • Paladin of the Pegasos
    Paladin of the Pegasos
    Amigaharry2
    Posts: 1363 from 2010/1/6
    From: EU-Austria (Wien)
    What is "chelp"? What does chelp print in console?
    Peg2, 3xPowerMac G5, 2xPowerbookG4, 2x MacMiniG4, Efika (again), A3000T and life is never boring.....
  • »31.01.26 - 16:38
    Profile
  • MorphOS Developer
    Piru
    Posts: 608 from 2003/2/24
    From: finland, the l...
    Quote:

    EVX wrote:
    I am having a bit of rookie trouble getting the shell output to a file.

    What I see in the documentation is:

    command > file /A

    This only generates an empty file. I have tried creating the file first. I have tried >> to append the file.

    In my instance, I want to direct the output of the command "chelp all" to a file so I can print it.

    Please let me know what I am missing.


    Likely this command is printing the output to standard error. You can redirect standard error to file with:

    Code:
    command *>file


    You can also send both standard output and standard error to same file by using *>< for example:
    Code:
    command >file *><
  • »31.01.26 - 18:07
    Profile
  • EVX
  • Just looking around
    Posts: 14 from 2026/1/10
    I successfully made a file with the output from an different command (devlist) so my issue has been solved.

    devlist >Ram:devlist.txt

    Chelp is a CLI program to provide command descriptions in the shell. It appears that it pulls the command descriptions from a network connection. I suspect this must be my problem getting the output to a file. The chelp output is likely directed TO the shell and the redirect simply doesn't capture any of the data as I assumed it would.

    I didn't really have much need to redirect data to a file until I saw the size of the "chelp all" output. Of course, I picked a command that has a caveat to sending it's output to a file.... I am happy enough just learning about this and will hopefully stumble on an explanation in my future learning.

    Thanks for your help!

    Quote:

    Amigaharry2 wrote:
    What is "chelp"? What does chelp print in console?

  • »31.01.26 - 18:26
    Profile
  • jPV
  • Yokemate of Keyboards
    Yokemate of Keyboards
    jPV
    Posts: 2193 from 2003/2/24
    From: po-RNO
    Quote:

    EVX wrote:

    In my instance, I want to direct the output of the command "chelp all" to a file so I can print it.


    It is my script, but can't remember details how it works now :) I can check it better when I'm back home next days.

    But for printable material check its cache dir.
    HELP:english/Shell/ by default iirc. Shell_commands.txt or so.
    The wiki based MorphOS Library - Your starting point for MorphOS
    Software and other things made by me
  • »01.02.26 - 03:40
    Profile Visit Website
  • EVX
  • Just looking around
    Posts: 14 from 2026/1/10
    jPV, nice work on Chelp!

    Indeed, chelp places the data I need to print into Ram:T/Chelp_temp/Shell_Commands.txt

    As I'm learning more about shell commands, of course I chose Chelp for a quick reference in the shell for commands. It was just coincidence that I chose "chelp all" as the specimen for me to redirect the output. I do see the .lua file to have a look at so I will see what I can glean from it.

    All good, thanks guys!

    -E



    Quote:

    jPV wrote:
    Quote:

    EVX wrote:

    In my instance, I want to direct the output of the command "chelp all" to a file so I can print it.


    It is my script, but can't remember details how it works now :) I can check it better when I'm back home next days.

    But for printable material check its cache dir.
    HELP:english/Shell/ by default iirc. Shell_commands.txt or so.
  • »01.02.26 - 04:56
    Profile
  • jPV
  • Yokemate of Keyboards
    Yokemate of Keyboards
    jPV
    Posts: 2193 from 2003/2/24
    From: po-RNO
    More about this...

    Chelp is a shell ("AmigaDOS") script that has the Script protection bit set and it can be launched just like a command. It's only a helper script that actually calls LuaX and the main Lua script.

    I'm not sure if you can redirect a shell script output to a file at all... anyone remembers or has any tips?

    Basically if you launch a shell script with the Execute command, only Execute's own output (errors mainly) will be redirected to a file, but it seems that nothing that the given script does is redirected. It usually calls external programs that might output something, but it isn't catched with a rediretion of the main Execute command.

    In this particular case you could redirect output of the Lua script if you launch it by LuaX yourself, skipping the shell script completely...

    BTW. if you want to read loong outputs in the shell window, you can pause the output by pressing some key that enters a character into the shell, and continue by erasing the character then. I usually press the space bar for that, and continue with the backspace. But of course MorphOS has the scrollback buffer also, so it's not that important trick as it used to be on Amiga :)

    And you can also save the shell output to a file from the Review menu in the Shell window if you can't use redirection for some reason.
    The wiki based MorphOS Library - Your starting point for MorphOS
    Software and other things made by me
  • »02.02.26 - 06:12
    Profile Visit Website
  • EVX
  • Just looking around
    Posts: 14 from 2026/1/10
    jPV,

    Thank you very much for the explanation. It all makes sense now, but at the moment I tried the redirect, it was surely a mystery.

    This script impresses me for it's (usefulness &) ability to use a network connection. I'll get on with my shell learning for now and then have a look at this gem!

    Cheers,

    -E



    Quote:

    jPV wrote:
    More about this...

    Chelp is a shell ("AmigaDOS") script that has the Script protection bit set and it can be launched just like a command. It's only a helper script that actually calls LuaX and the main Lua script.

    I'm not sure if you can redirect a shell script output to a file at all... anyone remembers or has any tips?

    Basically if you launch a shell script with the Execute command, only Execute's own output (errors mainly) will be redirected to a file, but it seems that nothing that the given script does is redirected. It usually calls external programs that might output something, but it isn't catched with a rediretion of the main Execute command.

    In this particular case you could redirect output of the Lua script if you launch it by LuaX yourself, skipping the shell script completely...

    BTW. if you want to read loong outputs in the shell window, you can pause the output by pressing some key that enters a character into the shell, and continue by erasing the character then. I usually press the space bar for that, and continue with the backspace. But of course MorphOS has the scrollback buffer also, so it's not that important trick as it used to be on Amiga :)

    And you can also save the shell output to a file from the Review menu in the Shell window if you can't use redirection for some reason.

  • »04.02.26 - 04:17
    Profile
  • jPV
  • Yokemate of Keyboards
    Yokemate of Keyboards
    jPV
    Posts: 2193 from 2003/2/24
    From: po-RNO
    Quote:

    EVX wrote:

    This script impresses me for it's (usefulness &) ability to use a network connection. I'll get on with my shell learning for now and then have a look at this gem!



    Thanks, I think it's pretty cool myself too :) The network part is made with wget nowadays, but it used to be with the TCP: device without any external dependencies at first. The TCP: device solution didn't support the HTTPS protocol where MorphOS Library moved at some point, so I changed it to wget. The Library seems to work with HTTP again nowadays, so it could be possible to revert back, but I don't know if that's necessary after all.
    The wiki based MorphOS Library - Your starting point for MorphOS
    Software and other things made by me
  • »04.02.26 - 04:51
    Profile Visit Website