Questions tagged [scripting]

Scripting is a form of programming generally characterized by low formality, loose typing, and no requirement for explicit compilation. There are numerous scripting languages, and these are used in a wide variety of scenarios - command-line applications, GUIs, server-side applications, extension modules.

Scripting started out as storing a sequence of commands as a text file, and then feeding the text file into an interpreter or shell.

Early scripting-languages would just read, process, and execute one command at a time. There was no requirement to compile the script into a separate executable file. The source was the program.

Most modern scripting languages feature "interpreters" that perform an internal compilation step, and execute an intermediate code; but this is done automatically, transparently to the developer and user.

Examples of scripting languages are the Unix shells (Bourne and Korn shell, Bash, [t]csh, and zsh), Perl, and the special purpose language, AWK. Other examples include JCL (job control language), RPG, REXX, Windows/DOS BAT files, and MUMPS (used in medical applications). The world's most popular language, JavaScript, is a scripting language.

Over the last ten years, Powershell has become a popular scripting language under Windows, and has been extended to multiple platforms.

Most scripting languages support features such as:

  • dynamic typing
  • direct invocation of external commands
  • direct interaction with the file system
  • basic string processing
  • error control

Scripting languages are traditionally used for common system administration tasks like backups, and software installation and configuration.

Many scripting languages originated as special-purpose tools, and later evolved into powerful general-purpose languages over time. Examples here are Perl and JavaScript.

Over time, the distinction between scripting languages and more "traditional" compiled languages has fuzzed.

For example, interpreters for Python can actually cache its intermediate code, for faster startup times, much like programs written in traditional compiled languages. Conversely, traditional compiled languages are in some ways becoming more script-like, supporting dynamic data typing. The VAR type in the original Visual Basic is an example here, as is the dynamic variable type supported in C# 4.0.

Related tags

16278 questions
626
votes
7 answers

How do I get cURL to not show the progress bar?

I'm trying to use cURL in a script and get it to not show the progress bar. I've tried the -s, -silent, -S, and -quiet options, but none of them work. Here's a typical command I've tried: curl -s http://google.com > temp.html I only get the…
adammenges
  • 6,982
  • 3
  • 23
  • 27
621
votes
14 answers

Find and Replace Inside a Text File from a Bash Command

What's the simplest way to do a find and replace for a given input string, say abc, and replace with another string, say XYZ in file /tmp/file.txt? I am writting an app and using IronPython to execute commands through SSH — but I don't know Unix…
Ash
  • 21,088
  • 34
  • 100
  • 145
556
votes
10 answers

Why do you need to put #!/bin/bash at the beginning of a script file?

I have made Bash scripts before and they all ran fine without #!/bin/bash at the beginning. What's the point of putting it in? Would things be any different? Also, how do you pronounce #? I know that ! is pronounced as "bang." How is #! pronounced?
node ninja
  • 28,340
  • 55
  • 153
  • 242
529
votes
27 answers

How can you find and replace text in a file using the Windows command-line environment?

I am writing a batch file script using Windows command-line environment and want to change each occurrence of some text in a file (ex. "FOO") with another (ex. "BAR"). What is the simplest way to do that? Any built in functions?
Ray
  • 169,974
  • 95
  • 213
  • 200
503
votes
29 answers

How do I get the path and name of the file that is currently executing?

I have scripts calling other script files but I need to get the filepath of the file that is currently running within the process. For example, let's say I have three files. Using execfile: script_1.py calls script_2.py. In turn, script_2.py…
Ray
  • 169,974
  • 95
  • 213
  • 200
494
votes
129 answers

Stopping scripters from slamming your website

I've accepted an answer, but sadly, I believe we're stuck with our original worst case scenario: CAPTCHA everyone on purchase attempts of the crap. Short explanation: caching / web farms make it impossible to track hits, and any workaround (sending…
Dave Rutledge
  • 5,475
  • 7
  • 25
  • 24
488
votes
10 answers

How to get a password from a shell script without echoing

I have a script that automates a process that needs access to a password protected system. The system is accessed via a command-line program that accepts the user password as an argument. I would like to prompt the user to type in their password,…
BD at Rivenhill
  • 10,715
  • 9
  • 42
  • 49
475
votes
18 answers

Get name of current script in Python

I'm trying to get the name of the Python script that is currently running. I have a script called foo.py and I'd like to do something like this in order to get the script name: print Scriptname
SubniC
  • 8,049
  • 2
  • 24
  • 30
413
votes
6 answers

Get just the filename from a path in a Bash script

How would I get just the filename without the extension and no path? The following gives me no extension, but I still have the path attached: source_file_filename_no_ext=${source_file%.*}
Keith
  • 4,131
  • 2
  • 13
  • 3
384
votes
17 answers

Add a prefix string to beginning of each line

I have a file as below: line1 line2 line3 And I want to get: prefixline1 prefixline2 prefixline3 I could write a Ruby script, but it is better if I do not need to. prefix will contain /. It is a path, /opt/workdir/ for example.
pierrotlefou
  • 36,417
  • 33
  • 130
  • 168
379
votes
35 answers

How to urlencode data for curl command?

I am trying to write a bash script for testing that takes a parameter and sends it through curl to web site. I need to url encode the value to make sure that special characters are processed properly. What is the best way to do this? Here is my…
Aaron
  • 16,951
  • 4
  • 26
  • 23
375
votes
14 answers

How do I get the current username in Windows PowerShell?

How do I get the current username in Windows PowerShell?
Thomas Bratt
  • 40,822
  • 34
  • 113
  • 133
369
votes
14 answers

Scripting Language vs Programming Language

Can anyone explain the difference between Scripting Language and Programming Language please? Also can you state some examples for each. I have Googled a lot but I always find the best answers from Stack Overflow.
Rahul Reddy
  • 10,097
  • 9
  • 20
  • 21
363
votes
16 answers

Remove the last line from a file in Bash

I have a file, foo.txt, containing the following lines: a b c I want a simple command that results in the contents of foo.txt being: a b
Fragsworth
  • 28,413
  • 24
  • 76
  • 96
352
votes
21 answers

SQL Server - stop or break execution of a SQL script

Is there a way to immediately stop execution of a SQL script in SQL server, like a "break" or "exit" command? I have a script that does some validation and lookups before it starts doing inserts, and I want it to stop if any of the validations or…
Andy White
  • 81,400
  • 46
  • 171
  • 205