2

Is there an AS-400 equivalent of more or less, so I can page through command output? I'm connecting to the box using an AS400-specific telnet client called Telnet/400 (which I can't seem to find a link to online), but am happy to connect with another client if that'll make things easier.

2 Answers2

1

If you have OS/400 PASE, you should have many of the usual Unix commands available, including more.

It's possible that less would compile in PASE.

Are you getting a Unix shell when you telnet or are you in OS/400? The WRKDOC command may work for you. It's been a long time since I worked on an AS/400.

I don't know why your question was migrated to Super User. It should have been migrated to Server Fault.

Edit:

Qshell is very much like Bash or ksh. Here is a simplistic Bash function that acts as a pager in a pipe. You can use it like: ls -l | pager.

pager () {
    local line c
    while read line
    do
        echo "$line"
        ((c++))            # or use let c+=1
        if ((c >= 24))     # or use if [[ $c -ge 24 ]]
        then
            c=0
            read -p "--more--" </dev/tty # press enter to continue
            # a test for "q" for "quit" could be done here (using return)
            echo
        fi
    done
}

I have no idea whether the special device /dev/tty is available, but there may be an alternative. Or you can use something like this which is more cumbersome:

exec 3<&0; unset line c; ls -l | while read line; do echo "$line"; ((c++)); if ((c >=40)); then c=0; read -p "--more--" -u 3; echo; fi; done; exec 3<&-

Make the appropriate syntax adjustments, if necessary, as shown in the first example.

I can't believe that more is not provided. Even the ancient pg seems to be missing.

Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
  • Why does this require /dev/tty? Why can't I just use stdin? – Michael Kopinsky Dec 01 '10 at 00:39
  • I think that at this point, the solution of using F7/F8 is a workable one. While it doesn't provide all the same features of `less` (e.g. searching), it does provide an easy way to scroll up and down which is the main thing I needed. Writing a new script, figuring out what the `PATH` is or how to change it, etc. etc. simply isn't worth it at this point. – Michael Kopinsky Dec 01 '10 at 00:43
  • @Michael: You can't use stdin because that's where the lines of output from the command you're paging are coming from and they would answer the "more" prompt and cause output to continue without stopping. – Dennis Williamson Dec 01 '10 at 00:54
  • Right. Of course. – Michael Kopinsky Dec 01 '10 at 00:58
0

This is annoying, but for some reason I can't comment on either my question or Dennis's answer. Perhaps its because at the time the question was migrated, I didn't have an account on SU. In any case, this answer is essentially a response to Dennis.

I don't think PASE is available on the box I'm on. (Typing QP2TERM from the CL didn't do anything, and there's no /QOpenSys directory.) I have been working in qsh - it may be that there's a better way of getting stuff done, but at least qsh feels remotely similar to what I'm used to. It's like the feeling of that familiar can of Coca-Cola when you're in India and eating foods you're entirely unused to. :-)

In any case, I think I found my solution at this InfoCenter page. I can just hit F7 to scroll up and F8 to scroll down. It may not be as elegant as more, but it works and doesn't require me to ls a*;ls b*; ls c* etc. to see the contents of a directory.

  • @Michael: See my edited answer. (Coke Light is no substitute for Diet Coke, by the way (not metaphorically). But I made do when traveling.) – Dennis Williamson Nov 30 '10 at 20:19
  • You need a minimum of 50 reputation to comment. There's an exception for your own questions, but the question here is not recorded as "yours". – CarlF Nov 30 '10 at 20:28
  • Hmm, now the question does seem to be recorded as mine. I wonder what changed. – Michael Kopinsky Dec 01 '10 at 00:38