Skip to content

KALI – BASH Steampunk Scripting – How to automate Bash Scripts


BASH automates tasks, and Steampunk looks so cool, that we’re merging both together to get “Steampunk Scripting”.

Step 1 – Create the script

cat > steampunk

echo “Whatever text you feel like.”

Ctrl +d

bash cat steampunkNotice that wen you create the cat file, the cursor moves down to a new blank line, and that there is no prompt on that line.  Enter your echo “text” and then hit ctrl +d.

Think of ctrl +d as meaning “done!”.

Step 2 – Run the script

bash steampunk

kali bash scripting steampunkStep 3 – Add some commands to your script

You can easily “append” or “add to the end” of your script with the command >>

cat >> steampunk

Try adding these commands to your script, add each command one at a time.  End the script with ctrl + D, then run bash steampunk.


ncal -w


who -q

bash add to cat

You’ll quickly see why cat can’t be used for major automation….

So switch to nano or leafpad to correct any typos, as both are installed on Kali.

Step 4 – use nano to edit a script

nano steampunk

bash nano steampunk fileMake your edits… now these next 2 steps are really important.

To save a file in nano we use Ctrl + O

To quit = Ctrl + X


Here’s my amended steampunk script (viewed in nano).  I’ve hit ctrl +o to save.

bash nano amended fileHere’s the amended script when I run “bash steampunk”

bash nano amended steampunk outputwho -q = will tell you the number of users on a system…

That’s it.  That’s all automation starts with.  Shell programming can read input and prompt the user, as well as offering menu’s to the user.

But that’s for another lesson.  Oh, okay, lets do it now.

Step 3 – How to read input from a user

This reads the user input, secondly stores this input as a variable {users}, which thirdly, can be accessed using echo $users.

echo -n “Ask your prompt question?”

read users

echo $users

bash read script

The output looks like this

bash read values

Step 4 – Use a Prompt String

So what is this about?  Well with this format, we can read in multiple values from the user, save them into the default variable, called $REPLY.  We can then use echo $REPLY.

read -p “Prompt question to user? > “

echo “REPLY = ‘$REPLY’ “


Lets try it out.

bash prompt output

So we can read in single or multiple values.  We can save the input as a variable, and reuse that variable in our scripts.

Here’s the multiple values in action.

bash prompt multiple values

Bash Lesson 2 – How to create a timed lock out for a top secret password

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: