AIX IBM shell commands?

Posted on 2014-01-28
Last Modified: 2014-01-28
I am doing some research into AIX IBM security, and how to check certain settings. Most of the checks involve you executing commands such as "# ls", "# acl get", "# grep" etc. etc. I assume you run these commands in some equivalent to the windows command shell?
Does it have an option to write the findings out to a text file, as you can in command prompt i..e >filename.txt

And also is there anyway to execute these commands in bulk, i.e. if you had 200 commands,  is there a way to package them alltogether, run the packaged bulk of commands, and have each command write the outout out to a text file, so at the end of the scan all you have got is say 200 text files in the same folder?
Question by:pma111
  • 3
  • 2
LVL 68

Accepted Solution

woolmilkporc earned 500 total points
ID: 39814493
You can create a file in your current directory and put all your commands in it, named let's say mycmds, one per line.

You can then simply run this file with

sh mycmds

Output redirection works exactly the same way as in the command prompt. In fact, the command above starts a subshell of your login shell so the behavior of both is the same.

Thus you can append "> unique_logfile_name" to each command in mycmds.

Automating the logfile stuff is also possible, but would involve writing one more shell script, perhaps like this:

while read cmd
     eval "$cmd" > ${cmd%%" "*}.$n.out
  done < mycmds

Put the above in a new file in your current directory named e.g. runcmds
then issue "chmod+x runcmds" and run it like this:


${cmd%%" "*}.$n.out constructs an output file name consisting of the first word of the command, a dot, a serial number for uniqueness, and the appendix ".out"

I used "eval" to run the single commands in case you have special things like pipes etc. in them.

Author Comment

ID: 39814993
Thanks. Do you have to put any form of file extension of the mycmds file, so that the sh command can execute it?
LVL 68

Expert Comment

ID: 39815005
No, you don't. Unix/Linux shells don't rely on filename extensions.

Name your scripts as you like (to make your life easier choose meaningful names).

You can of course add ".sh" or something similar nonetheless to identify the file as a script at first sight.

Author Comment

ID: 39815014
wow, thought it would be loads more complex than that. Seems quite painless.
LVL 68

Expert Comment

ID: 39815017
Yep, it's Unix!

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Just about everyone has an old PC laying around.  Ask anyone in the IT industry, whether they are a professional or play in it as a hobby.  From outdated Desktops to cheap "throwaway" laptops, they are all around and not as hard to "fix up" as you m…
I don't know if many of you have made the great mistake of using the Cisco Thin Client model with the management software VXC. If you have then you are probably more then familiar with the incredibly clunky interface, the numerous work arounds, and …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question