What is scripting?
Scripting refers to the process of writing code in a high-level programming language to automate tasks, perform data processing, or create dynamic web pages. In simpler term, scripting refers to the process of writing small programs or scripts for a system to follow that automates tasks or processes. These scripts are typically written in scripting languages, which are programming languages, specifically designed for writing scripts. Scripts are often written by IT professionals, nonetheless, anyone can learn to write scripts. Take into cognizance that scripts have shorter, less structured development cycles as compared to the development of complex computer programs and software.
Unlike compiled languages, which require code to be compiled into executable binaries before they can be run, scripts are interpreted at runtime by an interpreter or virtual machine. This makes scripting languages highly flexible and adaptable, as changes to the code can be made and tested quickly without the need for a compilation step.
Scripting languages are generally easier to learn and use than traditional programming languages because they often have a simpler syntax and require fewer lines of code to perform a task. Albeit Scripts are often used to automate specific tasks, they can also be used for complex tasks if needed. They also often have built-in libraries and functions that make common tasks easier to perform.
What is a Scripting language?
A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Scripting languages are usually interpreted at runtime rather than compiled.
Some scripting languages include Python, JavaScript, PHP, Ruby, Perl, Bash, PowerShell, Lua, Tcl, R, Swift, Julia, Go, Rust, Groovy, Kotlin etc. Note that this list is not exhaustive and there are many other scripting languages out there.
Scripting languages, such as Python, JavaScript, Ruby, and PHP, are designed to be easy to learn and use and are often used for quick prototyping, automation, and small-scale projects. It is however crucial to note that some scripting languages are interpreted languages and are only compatible with certain platforms.
Why is it called scripting?
Why is the process of stating procedural instructions for a computer to follow or in a less complicated statement, why is the process of telling the computer what to do called scripting?
Well, the idea of a scripting language is one that instructs a host to carry out a series of actions (a lot like an actor reading from a script and then acting based on the outlined instructions in the script). It is called scripting because it tells the computer what to do and also how to do it. For example, JavaScript tells a browser what to do and how to process things just the same way that a shell script, PHP, or any other scripting language does for their respective hosts.
Types of Scripting in Programming
Types | Description |
Shell Scripting | This involves writing scripts in a shell language (such as Bash) to automate tasks in a Unix or Linux environment, such as file management or system administration. |
Web Scripting | This involves using scripting languages such as JavaScript, PHP, or Python to add interactivity or functionality to web pages, such as form validation or dynamic content. |
Data Scripting | This involves using scripting languages such as Python or R to manipulate, transform, or analyze large data sets. |
Build Scripting | This involves using scripts to automate software builds and deployments, such as using tools like Jenkins, Gradle, or Make to automate the build process. |
Testing Scripting | This involves using scripts to automate software testing, such as using tools like Selenium or Robot Framework to automate browser testing or unit testing |
KEYNOTE: Overall, scripting is a powerful tool in programming that can automate tasks, improve efficiency, and add functionality to software systems.
Benefits of Scripting
Scripting has several benefits, just to enumerate a few;
Automation: Scripting allows developers to automate repetitive or time-consuming tasks, such as file manipulation, system administration, and software testing. This can save time and reduce the likelihood of errors.
Flexibility: Scripting languages are often interpreted, meaning that code can be executed without the need for compilation. This makes it easy to modify and test scripts and to make changes quickly.
Portability: Many scripting languages are platform-independent, meaning that scripts can be run on multiple operating systems without modification. This makes it easy to deploy scripts across a variety of systems.
Rapid Development: Scripting languages are often designed to be easy to learn and use. This means that developers can quickly create scripts to solve specific problems, without needing to spend a lot of time learning a new programming language.
Integration: Many scripting languages are designed to work with other tools and systems. This makes it easy to integrate scripts with existing software and hardware systems and to create custom solutions that meet specific business needs.
KEYNOTE: Overall, scripting can help developers to work more efficiently, reduce errors, and create custom solutions that meet specific business needs, so start scripting so that you can join the large community of developers who are benefactors of scripting already.
Getting Started with Scripting
To get started with scripting there are a few things needed to be considered, they include;
Choosing a Scripting Language:
The decision of which scripting language to use will depend largely on the specific needs of the project, different projects require different libraries, frameworks and platforms. The experience of the developer involved and the experience of the development team, if you are working with one, will also be a deciding factor.
The table below contains a few scripting languages used in programming and the needs they meet;
Language | Description |
Bash Scripting | Bash is a Unix shell, which is a command-line interface for interacting with the operating system. Bash scripting is used to automate tasks on Unix-based systems |
JavaScript | JavaScript is a scripting language commonly used for web development. It is executed on the client-side and is used to create dynamic web pages and user interfaces. |
Python Scripting | Python is a general-purpose programming language that is widely used for scripting tasks. Python scripts can be used to automate tasks, manipulate data, and build applications. |
Perl Scripting | Perl is a scripting language used for text processing, web development, and system administration. It is known for its powerful regular expression capabilities. |
PowerShell Scripting | PowerShell is a scripting language used for task automation and configuration management on Windows operating systems. |
Ruby Scripting | Ruby is a scripting language used for web development, system administration, and automation. It is known for its simplicity and readability. |
PHP Scripting | PHP is a server-side scripting language used for web development. It is commonly used to create dynamic web pages and applications. |
KEYNOTE: Each scripting language has its unique syntax and purpose, and is used for different types of tasks.
Secondly, Understanding Basic Programming Concepts:
After choosing the appropriate language, you will need to understand basic programming concepts, failure to get adequate knowledge of the basics may lead to bad coding experiences in general.
Here are some basic programming concepts that you should understand:
Variables: Variables are used to store data in programming languages. They can hold different types of data, such as numbers, text, or Boolean values.
Data types: Different programming languages have different data types. Some common data types include integers, floating-point numbers, characters, strings, and Booleans.
Operators: Operators are used in performing operations on variables and data. Some common operators include + (addition), - (subtraction), * (multiplication), / (division), and % (modulus).
Control structures: Control structures are used to control the flow of a program. Some common control structures include if statements, loops, and switch statements.
Functions: Functions are blocks of code that can be reused throughout a program. They are used to perform a specific task and can be called from different parts of the program.
Comments: Comments are used to add notes to the code that do not affect how the code runs. They can be used to explain what the code does or to provide context for future programmers who may need to work on the code.
Debugging: Debugging is the process of finding and fixing errors in a program. It is an important skill for any programmer, as all programs will have errors at some point.
If you can cover the above topics then you may just be ready to write your first script. However, don’t let your learning journey end there you can continue with Advanced Scripting Concepts like;
Functions and modules
Object-oriented programming (OOP)
Regular expressions etc.
These topics will provide adequate knowledge to help enhance your scripting ability and problem-solving skills in general.
Lastly, Understanding the Syntax of the Chosen Scripting Language:
Understanding the syntax of a scripting language involves learning the rules and structure of the language, which includes things like keywords, statements, expressions, variables, and data types.
Here are some steps you can take to gain a better understanding of the syntax of any scripting language:
Read the documentation: The documentation for the language is the best place to start. It will provide an overview of the syntax, including the keywords, syntax rules, and any special features or quirks of the language.
Study example code: Look for sample code written in the language you are trying to learn. Analyze the code line by line and try to understand what each line does, and how it fits into the overall program.
Practice writing code: Once you have a basic understanding of the language, start writing some simple programs of your own. Start with basic syntax and gradually build up to more complex programs.
Use an IDE or code editor: Many Integrated Development Environments (IDEs) and code editors offer syntax highlighting, auto-completion, and other tools that can help you learn the syntax of the language more quickly.
Seek help from the community: There are many online communities where you can ask questions and get help from other developers who are experienced in the language you are learning. This can be a great way to learn about the nuances of the language and get tips on how to write more efficient and effective code.
Uses of Scripts
Albeit Scripting is primarily used for the automation of tasks which we would take a closer look at soon, below is an ample list of its uses;
Scripting for Web Development: Scripting is commonly used in web development to create dynamic pages and perform server-side processing and client-side validation. Scripting languages used in web development include JavaScript, Python, PHP etc. Frameworks and libraries for web scripting include Ruby’s
FileUtils
module for file and directory operations, and theNet::SSH
module for remote execution, Selenium, python’sFabric
for remote execution andPexpect
for automation of interactive processes, power shell’s .NET libraries. etc.Scripting for Data Science: scripting is used in data analysis to manipulate and process large data sets, Visualization and reporting can also be carried out with scripts. Scripting languages used in data science include Python, R, SQL etc.
Scripting for System Administration: scripting is also used in system administration to automate repetitive tasks, such as sending emails, copying files, or updating databases. Monitoring and logging are can be done with scripts too. Scripting languages used in system administration include Bash, PowerShell etc.
Testing and Quality Assurance: Scripts can be used to automate testing and quality assurance procedures, ensuring that software and systems meet specific standards.
Providing Customer Support: Scripts can be used to provide consistent customer support by providing standardized responses to common queries.
Improving Efficiency: Scripts can be used to improve efficiency by streamlining workflows, reducing errors, and eliminating manual tasks.
KEYNOTE*: Scripts are useful in many different contexts where a specific set of instructions or actions need to be followed in a consistent and repeatable manner.*
Since scripting is primarily used for Automation, let’s look a little into Automation.
Automation
What is Automation?
Automation holistically refers to the process of using technology to perform tasks or processes without human intervention. This can involve the use of software, robots, or other types of machines to complete tasks that would otherwise require human effort.
Automation is often used in manufacturing and production environments, where machines are used to perform repetitive or dangerous tasks. However, automation is increasingly being used in other industries as well, such as finance, healthcare, and transportation.
Uses of Automation
Some of the uses of automation may be found in;
Robotic Process Automation (RPA): This involves the use of software robots to perform repetitive tasks such as data entry or customer service.
Industrial Automation: This involves the use of machines and robots to perform manufacturing and production tasks such as assembly, welding, or painting.
Home Automation: This involves the use of smart devices and systems to automate tasks such as lighting, temperature control, and security.
Business Process Automation: This involves the use of software to automate business processes such as invoicing, payroll, or inventory management.
KEYNOTE*: Automation can help to improve efficiency, productivity, and safety in many different industries and applications*.
Automation and Scripting
Automation is used to replace a repetitive manual step with one that happens automatically, and scripting helps us to do that and more. Humans are fallible. They can become tired, make mistakes, fail to follow instructions, be inconsistent in their job performances, and more. In contrast, automated processes complete instructions exactly as programmed, in a consistent manner, and in a faster time duration. They can run 24 hours a day, every day, without tiring. For example, imagine the heavy traffic on the road being controlled by a traffic warder juxtaposed with the traffic controlled by the Traffic lights, will the traffic warder be more effective than the traffic lights? I am very sure that your response will not be in the affirmative. The traffic warder may get weak and bored after an hour or two, but the traffic light won’t get tired because it is automated by the traffic light protocol.
Appropriate and Inappropriate Usage for Automation
Albeit automation has proven to be invaluable to its benefactors, there is a need to ascertain when it is necessary to automate and when it isn’t.
For many tasks that are appropriate for automation, it can be more cost-effective to use automation than human labor. However automating tasks that are inappropriate for automation can be very detrimental to the developer, his resources and its end users if there are any. Before you automate anything make sure it is certainly appropriate for automating.
On the premise of that I have made a list enumerating some Appropriate and Inappropriate use of automation;
Appropriate Usage for Automation Include:
When appropriate tasks are automated, the need for repeatedly carrying out a particular sequence of procedures is eliminated. The following are some examples of tasks that can and should be fully automated;
The automatic timing and regulation of traffic lights
A repetitive task that is at high risk for human error
Sending commands to a computer
Detecting and removing duplicates of data
Sending automated emails that are personalized by pulling individual names from a database and plugging them into the email
Updating a large number of file permissions
Reporting on system data, like disk or memory usage
Installing software
Generating reports
Deploying a file or a computer program to all computers on a company network
Using a configuration management system to deploy software patches, after a human has designed the system
Populating an e-commerce site with products
Setting the home directory and access permissions for users
Inappropriate Usage for automation Includes;
Automation is not always an appropriate or complete solution. Automation cannot perform all human work. Tasks that call for human creativity, social connection, psychology, flexibility, ingenuity, evaluation, and/or complex analytic work are not good candidates for full automation. Sometimes automation can be used to perform one or more subtasks of a larger set of tasks – but – human intervention is required to complete the tasks. The following are some examples of tasks that cannot or should not be fully automated:
Items that require human evaluation and analytic skills:
Designing a configuration management system
Investigating and troubleshooting all end-user problems
Writing a computer program
Building a new startup business
Items that require human creativity and/or an eye for aesthetic qualities*:*
Designing an attractive webpage (AI can do this, but simple automation cannot)
Wedding photography
Haircuts and styling
Items that cannot be automated due to basic physics:
Troubleshooting or repairing machines that cannot power on or boot up
Items that need human interaction, psychology, and/or evaluation skills:
Interviewing and hiring new employees
Customer service (chatbots cannot address every customer service need)
Items that should not be fully automated due to costs and safety:
Grocery store checkout process, including bagging groceries
Tasks that are less expensive to perform manually
In general, automating task makes our life easier, and saves us time, energy, resources etc. whilst we are looking for ways to enjoy all the benefits of automation, understanding that not all tasks require automation will save us from getting into unpleasant situations.
This write-up doesn’t cover in absolute totality everything about automation and that is because it is just an introduction to automation, however, it is enough to get you started. There are several resources online that can give you ample knowledge on automation like www.alison.com, www.qmetry.com, INE’s Task Automation for network engineers, www.youtube.com, etc. The list is endless!
Artificial Intelligence
It is important to understand that basic automation is not the same as artificial intelligence. Automation is used to explicitly instruct a machine on how to perform a task. Artificial intelligence (AI) involves training a computing machine to perform more complex tasks through a process called machine learning. This process prepares the AI software to perform new tasks without a human needing to program explicit instructions for each task. Although AI is often used for automating human tasks, AI automation is much more complex than basic automation.
Conclusion and Further Learning
Recap of Key Concepts Learned
Scripting refers to the process of writing small programs or scripts for a system to follow that automates tasks or processes. Scripting is a powerful tool in programming that can automate tasks, improve efficiency, and add functionality to software systems
A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Some scripting languages include Python, JavaScript, PHP, Ruby, Perl, Bash, PowerShell, Lua, Tcl, R, Swift, Julia, Go, Rust, Groovy, Kotlin etc.
Benefits of Scripting Include; Automation., Flexibility, Portability, Rapid Development, and Integration.
Scripting can help developers to work more efficiently, reduce errors, and create custom solutions that meet specific business needs.
To get started with scripting, first Understanding Basic Programming Concepts, understand the language syntax and then gradually move to more advanced concepts.
Scripting languages include Python, JavaScript, Perl, Bash etc. Each scripting language has its unique syntax and purpose and is used for different types of tasks.
Scripts are useful in many different contexts where a specific set of instructions or actions need to be followed in a consistent and repeatable manner.
Types of Scripting include; Web Scripting, Data Scripting, Build Scripting, Shell Scripting etc.
Automation holistically refers to the process of using technology to perform tasks or processes without human intervention.
Appropriate Usage for Automation Include; The automatic timing and regulation of traffic lights, A repetitive task that is at high risk for human error, sending commands to a computer, Detecting and removing duplicates of data etc.
Inappropriate Usage for automation Includes; Items that require human evaluation and analytic skills, designing a configuration management system, Investigating and troubleshooting all end-user problems, writing a computer program, and Building a new startup business.
In general automating tasks makes our life easier, and saves us time, energy, resources etc. However, it is imperative to understand that not all tasks require automation.
Further Learning
INE's Task Automation for Network Engineers.
LinkedIn Learning.
Pluralsight.
edX.