Saturday, August 3, 2019

Job Update - Part I, Background Info

I figured I'd take a bit of time to write about what I'm doing now, though I'm going to write for the (hypothetical) layperson that I used to be.

I suppose I actually need to start with scripting. Or rather, the command line.

If your around my age or older, you may remember how computers used to be. You may remember sitting in front of a computer screen and seeing simple text. No fancy pictures, no windows. No mouse.

Just a (most likely black) screen where you could type in whatever commands you wanted.

Windows... heh. Well, they've been around so long it's easy to forget what it was like before.

Windows make computers much more intuitive and easy to use. You can easily see menu options, select what you want with a mouse, and more. But the older methods are still there.

For instance, if you're using a Windows machine you can go to the Start menu and find cmd.exe. ('cmd' will generally find it, but there apparently are malicious programs that will call themselves things like cmd.bat, so just to be safe I like to type the whole thing in.)

If you open it, it will give you a little black window with some text and a blinking cursor indicating where you can start typing.

You can type in commands here, just like on an older computer. Although it's not as easy to use, once you know the commands it can actually be faster. Mostly because the computer doesn't have to waste any time displaying a window, or re-sizing it, or modifying it to show your menu options.

If you wanted to find your IP address, you can search through some of the menu options on Windows (I don't know them off the top of my head, but I recognize them when I see them. It's probably under Network Settings or Control Panel -> Network or somesuch), or you can just open up the cmd.exe program and enter 'ipconfig'.  Iirc. The command terminal runs shells, and there are lot more than just cmd.exe out there. Windows created their own Powershell, which does some similar things (and has some differences)... and in Linux you're more likely to use Bash, though there are plenty of other options (like Korn shell), so in Linux instead of 'ipconfig' it may be 'ifconfig' or 'ip addr' depending on what version you're using. I can generally look them up if I need to, but it's actually just faster to type whichever seems correct and enter one of the others if it doesn't work.

I don't really want to get into the difference between a command line, shell, or terminal, suffice to say they all give you a place where you can run commands strictly through text.

So... why'd I even bring all that up?

Well, the next thing to understand is scripting.

Basically any command you can do in a shell can be written in a text file and run at will. You may not get much out of saving a script to run 'ipconfig' to your computer, but if you consistently do the exact same series of commands it makes sense to write a script. It's faster (since the computer doesn't have to wait on your slow data entry) and more consistent (since it will never forget a command, or put them in the wrong order).

If you wanted to, let's say, make a back-up of a particular file every day... you could write a script to copy 'important_file.txt' and paste it in another location under the name 'important_file_bak_YYYYMMDD.txt'. You can even (generally) tell the computer to run that script at a particular time every day.

That way your file is backed up at least once a day and once you've set it up to run you won't have to do another thing. (Okay, you might want to create another script to clear out older copies. Otherwise you'll eventually start running out of space.)

Why did I explain all that, you ask?  I'll explain in the next post. :)


No comments:

Post a Comment