Solved

AIX IBM shell commands?

Posted on 2014-01-28
5
747 Views
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?
0
Comment
Question by:pma111
  • 3
  • 2
5 Comments
 
LVL 68

Accepted Solution

by:
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:

#!/bin/ksh
n=1
while read cmd
  do
     eval "$cmd" > ${cmd%%" "*}.$n.out
     ((n+=1))
  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:

./runcmds

${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.
0
 
LVL 3

Author Comment

by:pma111
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?
0
 
LVL 68

Expert Comment

by:woolmilkporc
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.
0
 
LVL 3

Author Comment

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

Expert Comment

by:woolmilkporc
ID: 39815017
Yep, it's Unix!
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

895 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now