Solved

AIX IBM shell commands?

Posted on 2014-01-28
5
746 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
wow, thought it would be loads more complex than that. Seems quite painless.
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
Yep, it's Unix!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

762 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

13 Experts available now in Live!

Get 1:1 Help Now