Script is series of instructions written in plain text file. The script interpreter (i.e. shell, Python, Ruby, etc.) can read this file and act on the instructions as if they were typed at the command prompt. The interpreter also provides a variety of useful programming features to make your scripts ...

learn more… | top users | synonyms (1)

6
votes
1answer
1k views

How to send keystrokes to Chrome in Ubuntu?

I would like my computer to press the Esc key every 2 minutes. How can I do this? With and app or shell script or otherwise?
6
votes
2answers
24k views

Get wget output to a variable

How can I do it? I am trying it like this RESULT=`wget $URL` P.S. - Also any recommended sources for learning shell scripting?
6
votes
2answers
421 views

How can I delete numbered files in a given range?

I have folderA that has some files with a number sequence starting with a_000000. What I want to do is to delete files starting from a specific number: let's say a_000750 till the end of files in this ...
6
votes
2answers
734 views

How to use sudo with pipelines? [duplicate]

Possible Duplicate: sudo & redirect output Let's say I want to add some line into /etc/profile. I try: $ sudo echo "something" >> /etc/profile bash: /etc/profile: Access ...
6
votes
2answers
1k views

What is responsible for mounting disks listed in fstab?

What script/init process/whatever is responsible for reading fstab and calling mount, during the boot process?
6
votes
2answers
315 views

Total video time in a Directory

Is there a script(bash, python etc.) that outputs the total duration time of all video files in a Directory(recursively) ? For e.g on executing the following : script mypath it gives x ...
6
votes
2answers
850 views

Oneliner command to use kill given tcp port number instead of PID?

I often do e.g. sudo netstat -lpn |grep :8088 view the output tcp6 0 0 :::8088 :::* LISTEN 11189/java and then sudo kill -kill 11189 I'd ...
6
votes
3answers
2k views

Why does my shell script hang without the .sh extension?

I created a shell script /usr/local/bin/suspend with the following content: #! /bin/sh # Take an optional delay parameter if [ "$#" -gt "0" ]; then sleep "$1" fi # Put the system to sleep ...
6
votes
3answers
536 views

How do I add a program that must be run from within its own directory to the panel or main menu?

Some programs can only be run from within their own directories. If I go to System --> Preferences --> Main Menu --> Add Item and select the file, it will not work. Similarly, if I right ...
6
votes
3answers
4k views

How to completely restart script from inside the script itself

I'm setting up a shell script with menues and sub menues, options, etc. But on each menu/submenu/etc, i need a "Go back to main menu" choice. I've already got the menu set up and it works fine, but i ...
6
votes
2answers
9k views

Writing scripts with arguments?

I want to write shell script that takes an argument, and then applies it to files. Specifically, I want to give a term, and then have it compile term.as with mxmlc ("mxmlc term.as"), then run ...
6
votes
3answers
846 views

directory name with space and bash

I'd like to exclude the directories "temp" and "Ubuntu One/" from backup. What is the correct escaping of the space???? RSYNCCONF="--delete --exclude=.* --exclude=temp/" Thanks in advance! Chris ...
6
votes
1answer
8k views

How to create Excel xlsx files from a script?

I'm looking for packages available in Ubuntu main/universe repositories able to create Excel 2007+ xlsx files from a script (python or perl) My requirements: 100% compatible Excel XLSX files. Solid ...
6
votes
2answers
1k views

Enabling unattended-upgrades from a shell script

I have a shell script to automatically configure new Ubuntu virtual machines for my purposes. I would like this script to install and enable unattended-upgrades, but I cannot figure out how to do so ...
6
votes
3answers
3k views

Command to activate (either run or bring to front if already running) a program

I want to be able to have a keyboard short-cut to either start or bring to the front a program. (sqldeveloper if it matters) I know how to run it, that leaves: 1) how do I find out if a program is ...
6
votes
2answers
5k views

What is the default character encoding?

I don't myself know how deep this question actually goes (for example, for all I know there could be several, depending on my task). Particularly, I am interested in what kinds of strings are used to ...
6
votes
1answer
243 views

What do these commands from a shell script do?

I'm just starting to learn bash. I have the following script, and I would like to know what does the following commands do in order to start to understand a little bit this world. if [ ! -w "." ] ...
6
votes
3answers
17k views

Proper way to add a user account via bash script

Here's the script code I'm using now: getent group $MYGROUP if [ $? -ne 0 ] ; then sudo su -c "groupadd $MYGROUP" fi sudo su -c "useradd mynewuser -p mypassword -m -g $PRIMARYGRP -G $MYGROUP" ...
6
votes
1answer
373 views

My bash function runs only once per terminal opened

When I try to run my bash function, defined in .bashrc, for a second time in the same terminal, it doesn't work. The code is the following: function nos (){ local option while getopts cs ...
6
votes
1answer
5k views

bash script source: No such file or directory

I have a script that begin like this #!/bin/bash VALKYRIE=~/myProjects/valkyrie source $VALKYRIE/cluster.conf but when I run it it returns line 2: ~/myProjects/valkyrie/cluster.conf: No such file ...
6
votes
1answer
4k views

How to automatically install entire Google Web Fonts collection?

I'm basically looking for an unattended way to deploy/install the Google Web Fonts collection into several Ubuntu boxes. I've searched for PPAs, packages or user scripts but without much luck. Any ...
6
votes
1answer
1k views

How to make gnome always run a script, not ask if it should be displayed?

I have written a script: for FILE in *.svg do inkscape --file=$FILE --export-area-page --without-gui --export-pdf=${FILE%.*}.pdf done which converts all SVG files in a directory to PDF. ...
6
votes
1answer
521 views

Create a script to open firefox with some google search term from terminal

Is there any way to create a script or a program that will open firefox, go onto google and search for the arguments passed to it ? So something like google How do I shoot web should open Firefox ...
6
votes
1answer
727 views

Can you help me write a script to set a new default brightness for the screen/keyboard after login?

On my Macbook Pro Ubuntu alsways boots with... keyboard brightness at maximum illumination screen brightness at maximum illumination ...both which I need almost never during normal usage. ...
6
votes
2answers
1k views

How can I create automated keyboard scripts?

Is it possible to do the following in Ubuntu? If so can someone point me in the right direction. Say you want to set a keyboard shortcut to do the following: For examples sake, set Alt+F to open ...
6
votes
8answers
3k views

Which download manager is capable of 'throttle' and 'pause & resume' a running instance of download from a script

When downloading big files it necessary to pause the download many times. A big file can be downloaded by using wget. First start download, then kill wget, then resume download by wget -c. I want to ...
6
votes
1answer
851 views

How can I make a script to place files older than each day before into their own folder?

I'm running an unnecessarily complex script which looks similar to this command: find /home/user/videos/*.avi -mtime +0 -exec mv -f {} "/home/nb/videos/1 day old" \; And then I run the same ...
6
votes
3answers
6k views

Run script as root at login (no sudoer user, shell session)

Much like /etc/profile and ~/.profile but ran by root instead of the user is doing login. /etc/rc.local runs after boot but I need running the script before login. The user is not a sudoer one. ...
6
votes
1answer
406 views

How to run a script when password is entered at the lock screen?

To toggle the enabling/disabling of my notebook's touchpad according to connected USB mouse, I used touchpad-indicator, which runs a daemon to monitor connected devices and take appropriate action. ...
5
votes
5answers
466 views

Needed simple script/loop/command for input command, execute and output within textfiles

Suppose I have list of commands in text file as below (cat cmdlist.txt):- cut lshw top awk sensors Now I want to get simple information on that command by whatis cut, whatis lshw etc. respectively ...
5
votes
3answers
362 views

Script for “extracting” subfolders into parent folder

This gonna be a little bit tricky, I guess :-) When I open a terminal in the folder and run a script, that script should: move all content of all subfolders to a top parent folder (recursively) ...
5
votes
3answers
4k views

How can I make a script run automatically after gdm login and logout?

I have a setup where my users log on using ldap and it works just fine. I want to run a script after my users login (its a script that will detect which groups they are in and map network shares ...
5
votes
4answers
10k views

Run a script only at the very first boot

Is there an idiomatic way in Ubuntu to run a script only the first time a machine is booted? (EC2).
5
votes
2answers
212 views

Why are my bash script's arguments causing an error?

In order to make uploading the code to github easily, I created a sh script #commit.sh git add . git commit -m $1 git push origin master But when I run it by saying ./commit.sh "comment1 comment2 ...
5
votes
2answers
4k views

How to check how long a video (mp4) is using the shell?

I need to ftp upload all the mp4 files in a directory with length > 4 minutes using the shell. I can't find any script to check how long a video is. Does anybody have any idea how to do that? Thank ...
5
votes
5answers
3k views

Which torrent client has command line arguments to start/stop downloads?

first of all, I want to create shell script to start/stop downloads in torrent client. I don't need CLI but if you know how I can do that with CLI using shell script then it is okay. I use ...
5
votes
1answer
6k views

How to loop through arguments in Bash ($1 $2 $3 and so forth)?

I have the following code snippet for num do echo $num done But I don't understand why it works! How come does Bash know to loop through my params $1, $2, $3, $... using my personal taste of ...
5
votes
2answers
588 views

Move multiple files to a dir if their names contain the same string present in dir name

I have multiple files in one folder: ABA.xy BEB.xy ACA.xy The same files with different extension in another folder ABA.rr BEB.rr ACA.rr Then I have single folder for each file name ABA BEB ACA ...
5
votes
4answers
1k views

How do I make an entire directory executable?

I have an entire folder dedicated to python scripts. I'm tired of doing chmod on every new python script that I write. Is there a way to make every file inside my folder executable if it is a python ...
5
votes
1answer
3k views

How to execute a script as super user first checking the user and getting pass from askpass if not super user

thers a similar question out there How can I determine whether a shell-script runs as root or not? I have the same doubt with different result Is it possible to, within the BASH script prior to ...
5
votes
5answers
2k views

How to collect all the “txt” and “log” files using find?

I currently have this script: find . -iname '*.log' -print0 | xargs -0 tar zcf $file To collect all the "*.log" files from a given directory. I would like to modify it to include also all the ...
5
votes
3answers
360 views

Count down script is not working

I am trying to create a script that will count down to 0 from what ever number I give it. Below is my script and basically nothing happens, no error message, I merely get the standard command line ...
5
votes
3answers
3k views

How to get longest line from a file?

I'm interested to find out the line number of the longest line from a file. For example, if I have a file with the following content: lalala tatatata abracadabra mu mu mu how can I write a bash ...
5
votes
2answers
175 views

How do I get a list of non-LTS packages installed efficiently?

I'd like to see to what extent my system is LTS-supported by means of what packages are supported for 5 years and which are not. I could disregard some non-5yr-supported packages, as some are rarely ...
5
votes
3answers
29k views

Run a script on login using ~/.bash_login

I need to run a script when I login and logout in my Ubuntu. I tried to put the script in my ~/.bash_login but it didn't work. Is there a better location where I can run my script? My script is ...
5
votes
3answers
1k views

How to download and install Oracle Java by a script?

The popular WebUpd8 Team PPA is not being updated. It has still obsolete versions like 8u45. I manually downloaded JDK from Oracle site and replaced it. Is there a way to automatically check Oracle ...
5
votes
3answers
8k views

Ubuntu 14.04 not running Bash scripts in /etc/cron.daily

I have a few scripts (that currently run in a CentOS system) I have moved to a new Ubuntu 14.04 system. These scripts are in the /etc/cron.daily to run once a day. These scripts are to run at the ...
5
votes
2answers
9k views

How to write Bash script What is the command to open a terminal with two different tabed terminals and execute some commands separately tabs?

How to write Bash script to open a terminal with two tabs, and execute commands in both tabs? for instance: tab 1 opens skype tab 2 opens chromium-browser In the end, I want one more thing: write a ...
5
votes
2answers
1k views

Shell Script to Toggle Between Two Commands

I need help creating a shell script to toggle between two commands. When it is run command1 is executed then if it is run again it executes command2 and so on...
5
votes
2answers
6k views

How can I run an application in gnome-terminal automatically when booting?

I need to run an application automatically when Ubuntu starts. I've got this app running without opening the terminal. However, this application displays some information in a terminal window and, ...