How To Create A Linux Shell Script
Posted On Sat Feb 19, 2011 By hostman In Linux Forums And Topics Discussions For Wallpaper Websites Running On Linux Servers Forums
on this page i will show you step by step on how to create a simple executable script using linux command shell i will give you all the commands you need to follow and at the ned you will have a linux script.
if you are starting to play with linux, eventually, you will find the flexibility that the linux shell provides. it provides you with so many possibilities to manage your linux box.
in this example, we are going to create a simple text file. this file will contain the commands to run. if you are familiar with linux, you know you can send commands to the shell, for example the date command shows today's date. so we are going to save a couple of commands in a text file to run when text file is executed
ok, lets get started and login to your linux computer.
Step 1. We are going to be using the cat utility to create a simple text file. from this text file we are going to run the commands.Type the following command to create a new file:
SHELL COMMAND:
Step 2. the cat command will take you to prompt mode.. here we are going to enter the shell commands to execute in our file.. so Type the following lines:
SHELL COMMAND:
Step 3. Check the file to be sure you typed correctly without any errors. display the contents of new_script file:
SHELL COMMAND:
Step 4. Try to run the file to see if the commands will execute.
SHELL COMMAND:
Step 5. Display the permission of the file by entering:
SHELL COMMAND:
Step 6. Type the following command to make new_script executable:
SHELL COMMAND:
Step 7. To see the new permission, enter:
SHELL COMMAND:
Step 8. Execute the new script by typing its name:
SHELL COMMAND:
Step 9. If you receive an error message such as: Command not found Type the following:
SHELL COMMAND:
as yo can see from the script output, it lists the files in your directory and the today's date.
note, the echo command. if you are familiar with PHP, its the same idea. echo is like using print command in other programming languages.
hope this helps, check out my other tutorials for beginners
if you are starting to play with linux, eventually, you will find the flexibility that the linux shell provides. it provides you with so many possibilities to manage your linux box.
in this example, we are going to create a simple text file. this file will contain the commands to run. if you are familiar with linux, you know you can send commands to the shell, for example the date command shows today's date. so we are going to save a couple of commands in a text file to run when text file is executed
ok, lets get started and login to your linux computer.
Step 1. We are going to be using the cat utility to create a simple text file. from this text file we are going to run the commands.Type the following command to create a new file:
SHELL COMMAND:
cat > new_script
Step 2. the cat command will take you to prompt mode.. here we are going to enter the shell commands to execute in our file.. so Type the following lines:
SHELL COMMAND:
echo Your files are
ls
echo today is
date
NOTE: Press ENTER to move the cursor to a new line and press CTRL-D to endls
echo today is
date
Step 3. Check the file to be sure you typed correctly without any errors. display the contents of new_script file:
SHELL COMMAND:
cat new_script
If there are errors, remove the file new_script and return to step 1 to create it again.Step 4. Try to run the file to see if the commands will execute.
SHELL COMMAND:
new_script
You will get a 'command not found' error because the files is not executable.Step 5. Display the permission of the file by entering:
SHELL COMMAND:
ls -la new_script
Notice that the file is not executable. You must make it executable.Step 6. Type the following command to make new_script executable:
SHELL COMMAND:
chmod +x new_script
Step 7. To see the new permission, enter:
SHELL COMMAND:
ls -l
You now have execute permission, as well as read and write permissions for the file.Step 8. Execute the new script by typing its name:
SHELL COMMAND:
new_script
All the commands that you typed into the file are executed, and their output is sent to the screen.Step 9. If you receive an error message such as: Command not found Type the following:
SHELL COMMAND:
./new_script
This command line tells the shell exactly where to find the shell script, new_script, in your current directory knows as 'dot.'as yo can see from the script output, it lists the files in your directory and the today's date.
note, the echo command. if you are familiar with PHP, its the same idea. echo is like using print command in other programming languages.
hope this helps, check out my other tutorials for beginners
vishaal Thu Jun 02, 2011
Thank you so much your Guidance and its really help me !!! I REQUEST to you Do more thing for learn in Linux and Windows and etc,,
God bless you all team :)
thanks with regards
vishaal
God bless you all team :)
thanks with regards
vishaal
Related Content
Information
Forums »
Linux Forums And Topics Discussions For Wallpaper Websites Running On Linux Servers »
How To Create A Linux Shell Script
Linux Forums And Topics Discussions For Wallpaper Websites Running On Linux Servers »
How To Create A Linux Shell Script
Title: How To Create A Linux Shell Script
Description: on this page i will show you step by step on how to create a simple executable script using linux command shell i will give you all the commands you need to follow and at the ned you will have a linux script.
Tags: linux , command , shell. terminal , server , computer , remote , remotly , ssh , putty , tutorial ,guide ,howto ,script
Info: This Post Has Been Viewed 0 Times Since
Date: Sat Feb 19, 2011
Author hostman Received 1 Replies #3072
Date: Sat Feb 19, 2011
Author hostman Received 1 Replies #3072
Share
URL: 

Embed: 

To embed this topic, just copy the code from the "Embed" box. Once you've copied the code, just paste it into your website or blog to embed it
BBCODE:: 

BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums
wallpaperama | Wallpapers | Forums | Terms Of Service
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5