An automated series of instructions carried out in a specific order, such as a Windows script created to launch a specific program on startup.

learn more… | top users | synonyms (1)

60
votes
6answers
3k views

How do perform commands in another folder, without repeating the folder path?

I was wondering if there's any clever way to do copy and move operations, or if there's a command to duplicate a file, without having to do a cd, then mv after, at the same folder. For example, I ...
34
votes
9answers
4k views

What scripting languages are useful in Windows? [closed]

What scripting languages are useful for Windows automation?
30
votes
9answers
10k views

Add directory to $PATH if it's not already there

Has anybody written a bash function to add a directory to $PATH only if it's not already there? I typically add to PATH using something like: export PATH=/usr/local/mysql/bin:$PATH If I construct ...
28
votes
10answers
16k views

How to execute a command whenever a file changes?

I want a quick and simple way to execute a command whenever a file changes. I want something very simple, something I will leave running on a terminal and close it whenever I'm finished working with ...
22
votes
11answers
41k views

Which command can I use to recursively rename or move a file in Windows?

What command in Windows emulates the recursive move / rename command from Unix?
21
votes
8answers
42k views

How can I run an application with command line arguments in Mac OS

Is there any easy way to append command line arguments to an application on a Mac? For example, to run Opera in kiosk mode or to use a different profile in Firefox, I can type $ ...
21
votes
6answers
19k views

How can I get a script to run every day on Mac OS X?

Cron? Launchd? iCal?? If so, how?
21
votes
2answers
22k views

SSH: execute sudo command

I have an interactive shell script, that at one place needs to ssh to another machine (Ubuntu based) and execute something as root (the user should enter his password, but the remote command should ...
20
votes
6answers
6k views

What is the difference between executing a bash script and sourcing a bash script?

What is the difference between executing a bash script like A and sourcing a bash script like B? A >./myscript B >source myscript
17
votes
6answers
69k views

Running bat file at startup as administrator in Windows 7

I'm currently running a startup script in form of a bat file successfully in Windows 7 (I've inserted a new registry key entry with the bat file path as value in ...
16
votes
5answers
2k views

Good PowerShell guide, getting started through more advanced usage

Does anyone have a really good tutorial or getting started guide for Microsoft's PowerShell? I'm a long time Linux/Unix user, and very familiar with scripting languages, command-line usage with bash, ...
15
votes
2answers
7k views

Bash Shebang for dummies?

I have some bash scripts I have setup that mostly use #!/bin/bash but I regularly come across some that look like #!/bin/bash -e #!/bin/bash -x #!/bin/bash -ex and so on. Can someone explain ...
13
votes
1answer
7k views

How to launch a command on network connection/disconnection?

I have a wifi connection that requires to authenticate using a web form once the wireless link is established. I know how to automate the authentication with a script that uses curl/curlIE. But how ...
12
votes
1answer
5k views

zsh with Cygwin

How can I configure zsh to be the default shell under Cygwin?
11
votes
4answers
15k views

Automatically run a script when I log on to Windows

How can I automatically run a script when I log on to Windows? I'd like to run this whenever I log into my computer: echo %USERNAME% logged on at %DATE% %TIME% >> log.txt A bonus would be to ...
10
votes
3answers
3k views

How do I launch a bash script from Finder in OS X?

How do I launch a bash script from Finder in OS X? I'm OK working at the CLI, but my little script is not so loved by my GUI-bound colleagues.
10
votes
1answer
5k views

Is there a way to call a script when Ubuntu wakes up from suspend or hibernate mode?

I have a little shell script that I run automatically when I log on to my Ubuntu machine; it will set the parameters of my touchpad the way I like it. However, when Ubuntu wakes up after being ...
10
votes
4answers
2k views

Move some iTunes library items to different drive?

My internal hard drive is somewhat small, and I only regularly listen to a fraction of my iTunes library anyway, so I'd like to keep large portions on it on an external drive for archival purposes. ...
9
votes
6answers
1k views

A script so that you don't forget your usb drive on a public computer

So I have a problem because I'm an idiot. I seem to always leave my usb drives in public computers at school and the like. I unmount them and log off leaving them still in the pc, and of course I then ...
9
votes
3answers
1k views

Calling a script with ./bla.sh vs. . bla.sh

Can anybody explain to me what the shell does in the two examples A) and B) below? It obviously behaves differently, but I can't find out why the output is different. Example: Let's have a script in ...
9
votes
3answers
7k views

Create a logoff script/task for Linux

In similar vein to my question for Windows and Mac OS X, how would one go about creating a logoff script for Linux? Any distro is fine, as I'm sure it'd be extendable across others. I'm most ...
9
votes
3answers
7k views

Looping Through Subdirectories and Running a Command in Each

I have a set of repositories sorted into directories based on their VCS (Git, Mercurial, SVN). With Subversion I was able to run svn update * in the parent directory and it would loop through each ...
9
votes
1answer
2k views

Where should I put my script?

Say I have created a bash script, which will make an ftp user, mount some paths for that user, etc. Where in the file system it would be proper to place? It would be good to have some resource clearly ...
9
votes
3answers
2k views

How to sync GreaseMonkey scripts between computers?

I have some great greasemonkey scripts for FireFox and would ideally have a way to sync them between computers. To some degree, it would even be nice to be able to deploy the scripts to PC's across a ...
8
votes
4answers
2k views

How to set a Linux Ditribution to self-destruct (to wipe everything from the system partition) via a script

I know this is a rather strange question, but I actually need to implement something like this for work. I shall be helping to facilitate a course that uses licensed software. The software is somewhat ...
8
votes
4answers
7k views

UNIX shell scripting: how to recursively move files up one directory?

I have a large number of small files, f, arranged in a directory structure like so: /A/B/C/f There are 11 directories at the level of A, each with about 100 directories at the level of B, each with ...
7
votes
2answers
30k views

How do I concatenate strings in a bash script?

How can I concatenate strings and variables in a shell script? stringOne = "foo" stringTwo = "anythingButBar" stringThree = "? and ?" I want to output "foo and anythingButBar"
7
votes
5answers
2k views

A way to find newest files in a directory, including subdirectories

I'm looking for a way in Windows to list all files in a given directory and its subdirectories, sorted so that the newest files are on top. Is there any easy way to do this? I'd also settle for a Perl ...
7
votes
3answers
5k views

Change DNS with script

I need to frequently change the DNS server address, and for now I do it by opening 'network and sharing center' - 'local area connection' - properties - ipv4 - and then type the DNS numbers. Is there ...
7
votes
4answers
3k views

Should I put *.sh and *.rb file extensions on all my scripts?

I have a bunch of hand-rolled executable scripts in my $HOME/bin directory. Some are written in bash, some in Ruby. All of them have the shebang line at the top telling the shell what interpreter to ...
7
votes
2answers
3k views

Can I make a script always execute as root?

How to make a script execute as root, no matter who executes it? I read about setuid but I'm not sure how to do this. I'm using Linux, Ubuntu 12.04 LTS.
7
votes
3answers
356 views

Multiple standard input? How?

From this commandlinefu post: $ diff <(wget -q -O - URL1) <(wget -q -O - URL2) Seems like multiple standard inputs but---if I remember my Linux Porgramming course correctly---this can't be ...
7
votes
2answers
248 views

Where should I put system-wide scripts in *nix system?

Can someone tell me of a sensible fairly standard place to put scripts that a number of users will need on an Ubuntu system?
7
votes
2answers
5k views

How can I access volume levels from the command line on Windows 7?

What I need I'm looking for a tool or a script that allows me to access the Windows volume levels from the command line. Ideally it would allow me to get and set all volumes including application ...
7
votes
5answers
15k views

Using Wget to Recursively Crawl a Site and Download Images

How do you instruct wget to recursively crawl a website and only download certain types of images? I tried using this to crawl a site and only download Jpeg images: wget --no-parent --wait=10 ...
7
votes
6answers
3k views

It is possible to make autocompletion in Powershell work like in bash?

I love Powershell, but coming from a Linux background there is a few things that is really bugging me. Like for example how the default auto completion works. For example: Get-PS expands to ...
6
votes
8answers
11k views

How to get my external IP address (over NAT) from the Windows command-line?

The Windows "ipconfig" command can only show me the parameters from the Ethernet interfaces from my machine (even with the ipconfig /all argument). It can show detailed information about the ...
6
votes
2answers
2k views

Playback random section from multiple videos changing every 5 minutes

I'm setting up the A/V for a holiday party this weekend and have an idea that I'm not sure how to implement. I have a bunch of Christmas movies (Christmas Vacation, A Christmas Story, It's a ...
6
votes
3answers
2k views

Ruby shell instead of Bash shell in Ubuntu?

It seems to me that Ruby is far more powerful, and you can also do more powerful scripting with it. Are there any open source implementations out there that could replace Bash with Ruby on Ubuntu, so ...
6
votes
1answer
5k views

Run a batch command for every file in a directory

I have a Java program working with this syntax: command.jar namefile I have to run this program for 1600 files in a directory. How can I run this command for every file automatically? Is there a ...
6
votes
1answer
886 views

How can I generate Pi to a given number of decimal places from a script?

Does anybody have a script that I could easily run like: sh generatepi.sh 10000 where 10000 is the number of generated π (Pi) decimal places.
6
votes
4answers
7k views

What's the easiest way to have a script run at boot time in OS X?

I want a script (bash/zsh/ruby/...) to run at boot time in OS X. What's the most simple way to do this, without messing with xml/plist files, and preferably not needing to make a meta AppleScript.
6
votes
2answers
4k views

How to extract text from pdf in script on Linux?

On Linux - How to extract text from a .pdf in which text really is text, not a scanned image? I want something I can use on the command line / in a script, not interactively. (I don't want to convert ...
6
votes
2answers
2k views

VIM plugin creation tutorial?

I'd like to make a script that executes a series of commands (basically just two lines): :v/\S/d :w But i cant find a tutorial about how's done. Anyone?
6
votes
3answers
764 views

Linux: How do I execute a script in a way that it knows its directory?

I need to write a script, which would be called from any location, but needs to run from the directory it resides in. The script should query its directory at runtime. How can this be achieved? ...
6
votes
6answers
1k views

Determine if command is recognized in a batch file

I'm writing a bat script in which I invoke a program (such as javac). For simplicity, I want to check if the command exists before I run it. i.e. If the command exists in PATH. For example, if ...
6
votes
2answers
3k views

How to execute a script on sleep, hibernate, resume, and shutdown

I keep alot of my classwork documents hosted on dropbox as well as my personal site for remote storage. This helps alot since I switch between an iPad, laptop and desktop, so there are no worries ...
6
votes
1answer
19k views

Migrating an iTunes Playlist from one computer to another

Awhile ago, I moved all of my iTunes music from one computer to another, but I did so without copying the actual iTunes library folder from one to another. Since then, the libraries have diverged. ...
5
votes
4answers
8k views

echo newline character not working in bash

I have bash script which has lots of echo statements and also I aliased echo to echo -e both in .bash_profile and .bashrc, so that new lines are printed properly for a statement like echo ...
5
votes
4answers
1k views

Fastest way to drain battery

I'm using Mac OS X 10.7.1 on a Macbook Core 2 Duo. What's the fastest way of draining the battery without crashing the system and preferable by using some sort of a script?

1 2 3 4 5 20