A few facts about scripting language and Why you need to know about Scripting

coding, computer, hacker, hacking, html, programmer, programming, script, scripting, source code, Free Images In PxHere

Is scripting being used in automation?

Scripting can be a powerful tool for anything in the industry from building cars to even creating orders to ship.   Each one has a specific reason to be there,  in all there are many reason why it makes it easier for the user to have scripting.   I know in my life, scripting can be used in many different reason.   For one you could have a PowerShell script to automate a process to wake the daemon or make a service synchronize a service.  In all even in the Microsoft world there are services that need to be restarted or maybe just synched due to the daemon not keeping up.   Having seen this and having to do it from time to time or even create a script to run every hour to keep the what ever might need to be synchronized up to date.   Is that something hard to do or easy, the real questions you should be asking yourself is can you really do it and not make any mistakes?   After all, we are human and bound to make a mistake or two.   So we have to at least consider how any script will affect us in the long run.    Scripting can definitely make certain tasks so much easier when something arises that needs to be done to a server or even process.

What are the options for a script?

Before we begin the options we have to at least consider why scripts are so vastly different from applications.   The short answer is that they can’t do nearly the things applications can because they aren’t integrated into the kernel or there might be processes that the script can’t do without SU permissions and programs can have SU permissions and run in the background without any need for verification from the user.  Now let’s at least talk about the options for what a script  be used for or how we should at least consider it to be used.   First and foremost is to restart a process, and this one is the most common I have seen in the past.   I used to have to restart the Xorg services or drivers due to how the applications caused it to crash for one reason or another in Linux.   This was definitely when the drivers for Nvidia and AMD were still relatively new to the Linux environment.   It would on occasion need to be restarted and people started to have script to use to do that so they didn’t have to write the same codes down each time to restart the service.  This was truly cutting edge for Linux to be able to use a script to restart the graphics drivers and allow the user to continue to use their computer.   Another good option for tasks that can be scripted is downloading files that you might use for Windows and have them update with newest version as they are coming.  You could even create a script to download all the Windows Updates on Linux just like you can on Windows to be able to install them offline if the need arises.

Scripts are just Amazing!

As you can see, I really do love to use scripts and have in the past come up with scripts that can be used for the people who use Linux or might need a script for a certain situation.   Each person can come up with some truly amazing scripts to share with others to help make working in the Linux environment even more better for everyone.  Do you agree or disagree?  Do you have a favorite script you want to share with others?  why not leave a comment and let people know your script and tell them what OS it can be used on.   I am going to link a few good useful bash scripts to let you explore even more.

 

Understanding Shell Script in Linux Mint and how to use it properly

 

Shell script

Shell scripts are powerful!

Any Admin who has used shell scripts to complete a bunch of tasks on Linux will tell that you should already be using it.  It’s something that even I can’t really understand but know a lot about since I have to install Linux a lot.   Sometimes it can go weeks before I have to use my shell script again or the next day.  It varies from time to time when I will need to use it but it is an admins best friend.   Is shell scripts like python, absolutely but there is something that we should at least explore and understand.   I am going to talk about this and give examples for those who might want to follow along with me as we talk about “What is shell scripts and how can I use them?”.  I am sure this will be a long series maybe a few post here and there but it will be really good for those who might want to learn even more about the world of Linux.

Shell scripts vs python

Let’s at least get this one out of the way, because someone is bound to ask this question.  What’s the difference in shell scripts verses python?  In the short answer not much, but in the long answer the python language is more complex and you can do a lot more with the python did you can do with shell but only to a point.  Each one has it’s own unique qualities and can be used on Linux and Windows.   Although shell scripts can’t be run on exactly, they can be renamed to be batch files (.bat) which is DOS(Directory of System) old system.  Way before Windows we had DOS and way before any GUI interfaces we had to create batch files to load up the system.  If you’re old enough you probably remember autoexec.bat or even the config.sys files that you occasionally had to edit to get to the command prompt.

Shell scripts in Linux

What’s the use of using shell scripts in Linux you might be asking yourself?  It’s very useful to use when there is a problem or need to install a bunch of things that would take longer to install individually.  Shell script basics are really just that like a batch file in DOS and it can do a lot of things from asking a question to installing many different files.   It can rename or remove files, it is also good for cleaning up a directory that might be full of junk files or maybe you want to have a shell script to backup your /home directory.  This is the power of shell scripting in Linux.  Shell script basics can make your life so much easier and better in the long when you finally decide to delve into the Linux system.

Shell scripts If and then

Just like batch files, you can use this in Shell scripting.  If something happens then do this or you can even go farther that by using Else statements also.  You can ask something from the admin like where the file location of a file you want to use.  It can make your life so much simpler and can help keep the Linux system running smoothly.

if [ expression ]
then
statement
fi

You can do so much more with the shell script when you personalize it to what ever you might need.

echo What is the shell script you want to run?
read $FILE
if ! [ +r $FILE ]; then
Echo "Admin permissions are required to run this shell script"
then exit 0

As you can see this can be very useful when you want to get around certain installation situations and needing to install files without prompting.

Here’s a good one for those who might need to do just that:

echo y|sudo apt-get install [apt program]

This will allow you to bypass the yes question when it is asked and you can just create a basic shell script to install the files that you wanting to do like I have from time to time with gaming systems.   If you don’t want to wait around and install them manually this is the best approach for people who might want to multiple programs at once.

Executing the shell script

if you can’t execute the shell script than you haven’t given permissions to execute it in Linux.  You either have edit the properties in Linux, by right clicking on the shell script and clicking on the properties tab.   Then check “Allow executing file as a program” or you can do a command line

chmod 0700 script.sh (only allow owner to run script)
chmod 0755 script.sh (Allow owner users, and groups to run script)

As you can see the chmod command can be very useful in Linux, so take care to use it wisely.   I will talk about even more about shell scripting in the coming days and hopefully provide you with a very powerful script for installing all the gaming and even the drivers that you might need to for your new Linux gaming system.