Linux basic scripting (similar to batch script in Windows)

I have to build a Buch of machines in work and have 30 odd linux commands to run. We use CentOS and I'm trying to find out if I can automate the process a little by having a script that cycles through the commands so I don't have to keep copy and pasting them.

I'm new to linux and could write a batch script in Windows but don't know what the linux equivalent is to search in google.
I would like to keep each command on its own line in a file, then have a window that basically asks the user "do you want to run this command xxxxxxxxxxx"
The user then presses "y" and it goes onto the next one etc etc.

Is this easy to do in linux?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Travis MartinezStorage EngineerCommented:
It is rather easy with the "read" statement in your script.  This is kind of difficult to expand upon without further information.
Travis MartinezStorage EngineerCommented:
Here's a basic example and output:

$ while [ $x -eq 1 ]
> do
> echo "hello world /n"
> echo "would you like to continue (y/n)"
> read answer
> if [ "$answer" = n ]
> then $((x++))
> fi
> done
hello world /n
would you like to continue (y/n)
hello world /n
would you like to continue (y/n)
hello world /n
would you like to continue (y/n)
As Travis pointed out with an example, the answer is yes.

There are many possibilities, but lack of information on what the tasks are, it is hard to answer
The short answer is yes, sh, bash, zsh, ksh, csh are the basic scripting somewhat equivalent on a level to batch scripting since they rely on the execution of other commands to do things.
There are other scripting option as does Windows that are more robust in the same comparison vbscript, powershell on Windows such as perl, TCl/ti, Python, php.....

The optimal choice depends on what the tasks are.
Getting user input is the least as read in the example provides, once you get the user input what then?

The shell, batch scripting requires that you harness the response from one command and can pass it to the next one, the more robust scripting avail the option to handle the flow in a more seamless wait, less probe to typo, or oversight that while you expect the prior respinse to be passed to the next command..

If the task is simple, execute the following commands in a sequence without interdependency I.e. Execution of this command does not depend on the execution of the prior.
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

PJ0302917Author Commented:
Hi guys, thanks for looking into my question and helping me out. I've not used Linux much and a Shell Script seems to be the way to go.
As far as additional details go, I'd like to code the following.
1) A master script which the user runs and interacts with
2) Configuration files which contain commands such as make directory, copy files, change privileges etc. There could be a number of configuration files but only one master script.

So the master script will start up and list all the configuration files found in its local directory. User inputs number 4 to load configuration file 4.

I guess the master script will use the "read" command to iterate each line of the configuration file and execute the command.

In the master script the user is asked if they want to run "mkdir Test_Files"   (this is the first line of Configuration File 4)
User presses 'Y'
master script then states "mkdir Test_Files successful"
master script then asks if they want to run "cd Test_Files"    (this is the second line of Configuration File 4)
User presses 'Y' etc etc
Where does this master script create files?
Issue, to create thing outside the user's home dir will require the script to run with elevated rights.
Travis MartinezStorage EngineerCommented:
Are you more familiar with PowerShell?  You can install the shell as a package on the base CentOS image.  Not sure if that would help put the scripting knowledge back in the wheelhouse you're familiar with:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.