Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Use of scripts?

  1. #1
    Join Date
    Nov 2012
    Beans
    39
    Distro
    Ubuntu 13.04 Raring Ringtail

    Use of scripts?

    I'm confused when and why would you need to use scripts?

  2. #2
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Use of scripts?

    To automate tasks?
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  3. #3

    Re: Use of scripts?

    That all depends on the meaning of the word "script". The question of what is and is not a script tends to degrade into a heated argument nearly every time it comes up, so here are a few examples of programs that may or may not be considered "scripts" that are very useful.

    * Portage, Gentoo's package management system, is a program written in Python, which many would call a "scripting language" (another semantic minefield). It's pretty big and incredibly useful. I'm drawing a blank on similar programs available for Ubuntu at the moment.
    * Anything in /etc/init.d. These are startup scripts and your computer won't function usefully without at least some of them.
    * Any Web page, including the one you're currently reading, generated by a PHP (or Perl or whatever) script. Facebook wouldn't exist without scripts, and whatever you may say about Facebook, it's surely useful.
    * A file containing commands to automate some task in a specific program. Some programs are scriptable in languages like Lua, Tcl, Python, VBA and various forms of Lisp. Other programs have their own scripting languages. In either case the goal is to make using the program easier.
    * Any short program written to make a complex task easily repeatable. I'm considering writing a script to restore my keyboard layout settings after resume from suspend because Xfce always borks them up somehow.
    * Any short program written to make a tedious task simple. I once wrote a Perl script to rename all my .jpegs to the format yyyy-mm-dd hh:mm.jpeg (or something like that) so that they would sort in the proper order. If one-liners count, I wrote one of those the other day to line up a ragged chunk of source code.
    * Any short program. Self explanatory, really.

    There's a lot of overlap between these categories and I don't think I've covered all the possible meanings of "script", but hopefully it's clear that scripts by anyone's definition are used for a lot of things and computers would not be the same without them.

  4. #4
    Join Date
    Nov 2012
    Beans
    39
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Use of scripts?

    Aaa i see now thanks

  5. #5
    Join Date
    Jul 2011
    Beans
    206

    Re: Use of scripts?

    Tossing in a couple more pennies here...

    I believe the 2 things to understand about a script, is that 1) it's a program, and 2) that it's written in plain text. It doesn't get compiled into a form that's not human-readable. If you have the authority to examine the contents of the script, you would be able to read it in a plain text editor. Like any program, a script will have special terms to call for functions; things that need to be done. This includes looping and conditional branching. But, it remains a plain text file, and is denoted as being a program (a script) via the executable bit being set. I'm sure there will be some who disagree, but I think if it got compiled out of being human-readable, then it's no longer properly termed a "script".
    .
    "That's my motto - a place for everything, and everything all over the place!"
    -- From an old comic I once saw.--

  6. #6

    Re: Use of scripts?

    Eh, that's a perfectly reasonable rule of thumb, but it's not definitive. For one thing, according to your definition, a program can't really be called a script until it's run. If I wrote a program intending to chown +x it and run it that way, and then when I was done, changed my mind and compiled a binary file, does that mean what I was doing wasn't scripting? Even if the development process and end result are identical?

    "Script" is an ambiguous term and I just don't try to rigorously define it. Same deal with "embedded" or the difference between hardware and software.

  7. #7
    Join Date
    Apr 2013
    Location
    43.49°N 7.46°E
    Beans
    117
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Use of scripts?

    IMHO the main difference between a program and a script could be that the first is more complex than the second, i.e. a program contains more functions and procedures than a script.
    However I agree with what trent.josephsen wrote: "script" is an ambiguous term, as well as "scripting language": e.g. you can create big applications with python, although that programming language is defined "scripting language".
    Last edited by alan9800; May 8th, 2013 at 05:10 AM.

  8. #8
    Join Date
    Jul 2011
    Beans
    206

    Re: Use of scripts?

    Actually, the ambiguous term is "program", because it's got more than one meaning. At most basic, it's a sequenced set of elementary operations for accomplishing a task. But, it's also used for a sequenced set of commands automating a task, compiled into a binary executable, no longer human-readable. Before & after compilation, the sequenced set of instructions can be the same - but, the actual contents of the files are very different. Even further, if I flowchart to diagram the sequence of instructions for automating a task, that too is called a "program". The flowchart & the typed in programming language commands are both human-readable, and the compiled version is machine code - but, they're each called a "program".

    Reading what I wrote previously, I have to agree that it didn't make the grade. Here's why:
    When I first got into the study of data processing, I was taught that originally a script was a series of commands in a high-level shell language that could be typed in line-by-line at a terminal, with each line executed immediately, and achieve the same result as if it was run as an executable. This included commands for conditional testing, and looping within a single line. Shortly after that, the definition expanded to include automation of branching & looping between sections in the shell script. However, the scripts never left the condition of being human-readable, and the term "script" was always used in reference to a sequence of commands executed in a shell such as bash or DOS. Length was never referenced; scripts could be any length at all; i.e., 1 command or > 1000.

    Obviously, things have changed a lot in the past 30 years,... I'm sure the current definition of "script" has changed, but if it's now vague is that an indication that its meaning has faltered, or that improper use of the term became commonplace & subsequently the dominant definition?

    I'd never heard that said about python, that it's defined as a "scripting language". I wonder if that's an indication of its original usage, or misuse of the term "scripting"?
    .
    "That's my motto - a place for everything, and everything all over the place!"
    -- From an old comic I once saw.--

  9. #9

    Re: Use of scripts?

    "Program" is also ambiguous, but that doesn't mean that "script" isn't. What you were taught 30 years ago was no more definitive then than it is now.

    It's a pretty stupid semantic nit to argue about though. //

  10. #10
    Join Date
    Jul 2011
    Beans
    206

    Re: Use of scripts?

    You bet! (Fun, isn't it?)
    .
    "That's my motto - a place for everything, and everything all over the place!"
    -- From an old comic I once saw.--

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •