Transcript for:
Scripting Languages 71

One topic you'll hear quite a lot of in information technology is automation and scripting. There are a lot of different ways to automate processes and we have a number of different scripting technologies available to us. But you have to make sure that you're using the right script for the right purpose. The type of scripting language that you choose may be based on the application you're running or the task that you're performing or it might be specific to an operating system and there might be a limited number of options available in that OS. This means that you'll probably learn a number of different scripting languages so you can automate regardless of what task you're performing. If you're running an automated task in Windows, you could be running a batch file. You'll know this because the name of the file has aBABBAT file extension. This is something that you'll run at the command line inside of Windows, but the use of batch files goes back to DOSs and OS2. This means that you have decades of documentation that can help you build a batch file to automate processes inside of your Windows system. If you're a Windows system administrator, then you're probably not using a batch file, but instead you're using PowerShell. This is a command line that's a bit of an upgrade from the batch file days and it provides a number of additional capabilities, especially for system administrators. PowerShell scripts commonly have a PS1 file extension. And if you're running Windows 10 or Windows 11, you can simply click the button to install PowerShell if it's not installed already. PowerShell scripts can take advantage of built-in functions referred to as commandlets. They allow you to extend the functionality of PowerShell to be able to access an operating system directly or be able to change things in the operating system that you normally wouldn't have access to from a standard command line and a batch file. You can even build these PowerShell scripts into standalone executables and simply distribute that executable to whoever needs to run that script. So, if you're doing any type of Windows administration or you need to administer a large Active Directory infrastructure, you want to become very familiar with Windows PowerShell. Windows also includes a generalpurpose scripting language that you can run outside of the command line. This is the Microsoft Visual Basic Scripting Edition. So, you can perform functions such as a back-end web server script. You can script on the Windows desktop itself, but you commonly see these VB scripts inside of Microsoft Office applications. These Visual Basic scripts are often identified with a file extension of VBS. As we mentioned earlier, if you're scripting at the Windows command prompt, you're using a batch file. But if you're scripting inside of Linux, you're using a shell script. Shell scripts are the process used inside of Unix and Linux to be able to automate inside of a Linux shell. Shell scripts don't require a specific extension type, but we commonly put ash on the end of the file so that we can easily identify them. If you look at the script itself, you'll notice that the first two characters of the script are a hash and an exclamation mark. This is known as a shebang or a hashbang and it designates that everything following that information is a Unix or Linux shell script. Another script that often works behind the scenes in our browser is JavaScript. These usually have ajs file extension and they're used for interactivity in our browser screens. So if you go to a website and you click something on the screen and notice that there's some interactivity that's all probably being created through the use of JavaScript. It's also important to keep in mind that there is a difference between JavaScript and Java. JavaScript is the scripting language that we use inside of our browsers. But Java is a programming language that you would use to create applications. These have a very different use, a different implementation and they were created by completely different organizations. So, if you're working with JavaScript, keep in mind that this is not related at all to Java. Cloud-based services have changed the way that we think about automation. This is because cloud-based services are not about a specific operating system or a specific work environment. Instead, we'd like to have scripting and automation done in the cloud that can be applied towards any operating system. That was part of the reason behind the success of Python. Python is a generalpurpose scripting language that works across many different operating systems and provides flexibility whether you're in Windows, Mac OS, or Linux. You'll often see Python scripts labeled with AP py file extension. Python has a great deal of support in the industry and has become very popular as a way to script across many different operating systems without having to change a lot of information inside the script. Here's a simple interactive shell script. It starts with the hashbang right at the beginning and it runs as a shell script. You can see the /bin /sh. It has a variable called input string that is being set to hello. And then there is a loop as part of the shell script. This has an echo which means it's putting information on the screen that says please type something in or type by to quit. And then it waits for you to input information into this script. When you hit enter, it echoes information to the screen that says you typed. And then there's a variable that repeats the information that you typed into the system. It will continue through this loop until you put in the string by. And at that point, it will say that you typed by and it will then quit the loop. This is a very simple example of being able to automate a process within a script. And as you become more comfortable with the scripting languages, you'll start creating longer and more complex scripts so that you can automate the things that normally you would have done manually.