A shell script is a script written for the shell, or command line interpreter, of an operating system.

learn more… | top users | synonyms (1)

5
votes
1answer
1k views

How to create Excel xlsx files from a script?

I'm looking for packages available in Ubuntu main/universe repositories (14.04) able to create Excel 2007+ xlsx files from a script (python3 or perl) My requirements: 100% compatible Excel XLSX ...
5
votes
1answer
258 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 ...
5
votes
2answers
159 views

How do I script juju deployment?

I have been working on a few juju charms and am ready to start testing a deployment of our services. Is there a standard method for deploying an environment? For instance, do I have to manually ...
5
votes
3answers
539 views

Where are logon and startup scripts for graphical settings located and how are they managed?

Where and how are the Ubuntu equivalent of your personal Windows configuration stored? Something akin to HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run as well as the Start Up menu. ...
5
votes
2answers
722 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 ...
5
votes
1answer
290 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 ...
5
votes
2answers
11k views

bash: [: too many arguments?

I'm trying to create a directory and cd into it: In ~/.bashrc: function abc() { appname=$1 appdir="$HOME/code/$appname" if [ mkdir $appdir -a cd $appdir ]; then echo Success else ...
5
votes
2answers
669 views

How do the environments of a standard Terminal command-line and a bash script differ?

I know there is something different about the environment of the Terminal command-line and the environment in a bash script, but I don't know what that difference is... Here is the example which ...
5
votes
1answer
1k views

Changing media key defaults in Gnome

Under XFCE, I had option to set my keyboard media keys to run particular programs or scripts. I understand the options to adjust the Keyboard Shortcuts under Gnome, but how do I change the default ...
5
votes
1answer
846 views

How to batch rename files (images) based on CSV file

What I have and want to achieve: There are thousands of images in one folder. I have a CSV file with following columns: A: original name B: renamed name A typical row looks like this: ...
5
votes
1answer
3k views

Bypass “Do you want to…” dialog after clicking script

After I create a bash script and double click it in Nautilus I am prompted with this - Do you want to run "sleepytime", or display its contents? With Run in terminal, Dislpay, Cancel and Run as ...
5
votes
4answers
917 views

A script for moving files from subdirs to parent dir

I am looking for a script for moving files from subdirs to the parent directory My folder structure looks like this. Inside of a folder A I have a lot of folders named 1,2,3,4,5... All these ...
5
votes
1answer
3k 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 ...
5
votes
1answer
2k views

How to set keyboard shortcuts from a script

I appear to be suffering from this bug that means my custom keyboard shortcuts are lost on reboot. I have 8 custom shortcuts, and re-setting all 8 via the GUI method for setting keyboard shortcuts is ...
5
votes
3answers
2k views

Removing numbers and hyphens from file names recursively

I am modifying a simple BASH script to remove numbers and hyphens from the start of my MP3 files. The aim is to rename files such as: 11 Song 1.mp3 1-1-Song 2.mp3 11-1 Song 3.mp3 to: Song 1.mp3 ...
5
votes
1answer
3k views

blackhole exploit kit - Linux Server Script

It has come to our attention when scanning some of our hosted server websites that they have been infected with Blackhole Exploit Kit (top dollar hacking program - ...
5
votes
1answer
809 views

Customize Gnome-Do's default action order

I'm using Gnome-Do with the "Files and Folders v2.5" plugin. I set it to read my .scripts folder, so that I might run my personal scripts from Gnome-Do. The only problem is that Gnome-Do's standard ...
5
votes
2answers
132 views

How to save images from web links given in .xls file

I have an xls file which has weblinks of product-images. The number is about 5000. Can you advise me how can I save these images on my computer. Given here below is a link just to narrate the example. ...
5
votes
2answers
4k views

Python script won't write data when ran from cron

When I run a python script in a terminal it runs as expected; downloads file and saves it in the desired spot. sudo python script.py I've added the python script to the root crontab, but then ...
5
votes
1answer
3k views

Start multiple apps running in shells split in one console

I need to start multiple apps running in shells and monitor their execution. Currently I have a main script that launches every apps in a new gnome-console but I would prefer to launch them all in the ...
5
votes
1answer
195 views

How to set my Bluetooth python script on higher priority than Ubuntu's request?

I have got a Bluetooth Python Server Script on Ubuntu to connect with an incoming request from a Smartphone device. However Ubuntu's Bluetooth is getting the request before my script can react on it. ...
5
votes
3answers
356 views

Convey some message to all users

Is it possible to write a shell script that enables any user (may not be root) to set a message(e.g. "Download on progress do not turn off" etc.) which will be conveyed like pop-up message (zenity or ...
5
votes
1answer
4k views

Script at /etc/init.d does not run at start-up

I wanted to run my Dropbox daemon automatically at start-up. I did it via terminal, that is, I (1) moved it to /etc/init.d, (2) made it executable, and (3) ran sudo update-rc.d dropbox.sh defaults. So ...
5
votes
1answer
280 views

NetworkManager run script before connection based on SSID

Is it possible to have NetworkManager run a script before it connects to a wifi network and pass the SSID of the network to the script (or just execute a script based on SSID)? I'm switching back from ...
5
votes
2answers
2k views

How to diff two folders to multiple patch files

I'm not much of a unix guy so I'll just go ahead and ask: I have a following problem - two folders with plenty of subfolders. I need to diff them. I tried this: diff -drupN vanila_kernel_3.0.8 ...
5
votes
1answer
9k views

rc.local is not always executed upon boot

Hey, I have some weird problem with the rc.local file which is located in /etc/rc.local the thing is that it is not always running when I boot up the laptop. Maybe every second time, I haven't ...
5
votes
1answer
596 views

Can I set up two key-bindings to launch the Main Menu? … specifically: Alt+F1 and Super

I've set up the Super key to open the main menu. It works. gconftool-2 --set /apps/metacity/global_keybindings/panel_main_menu --type string "Super_L" , I have a shell script super.sh which ...
4
votes
3answers
4k views

Is there a standard place for placing custom Linux scripts?

I am developing a set of scripts, which I want to be present for all users, when I set up a server. But I don't want them in the standard locations like /usr[/local]/[bin],[sbin] etc. Is there some ...
4
votes
4answers
273 views

How do I extract the version number portion from the version string?

How do I extract the version number from string=customer-asset-tag-1.0.2.9? Desired result: Component= customer-asset-tag version number=1.0.2.9
4
votes
1answer
1k views

Bash script: How to execute commands consecutively without waiting for the previous one?

In a bash script that execute 2 commands like this #!/bin/bash gedit nautilus Nautilus starts not before gedit is closed? How can i avoid this?
4
votes
2answers
977 views

Can I run command-line commands within a python script?

Sorry I'm kind of a noob at this: Basically I've downloaded this package that deals with text files that is run from the terminal, but the command I need takes in two arguments. I also need to do ...
4
votes
2answers
2k 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 ...
4
votes
2answers
8k views

bash script to login to webpage

I am trying to login into this page but I cannot for the life of me get it to work. I have to login to this site when i connect to my school's wifi in order to start a session. So far ive tried to ...
4
votes
3answers
19k 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 ...
4
votes
2answers
684 views

regex search works with `grep -E` but not with bash script?

I use the same regex with grep and it gives me a match but when doing it in a bash script, it return no match. Test String(part of the file testregex.txt): <a ...
4
votes
2answers
247 views

How do I iterate the arguments in a bash script?

Is there any method to iterate the passed arguments in a bash script? This answer from my question shows me how to use each argument, but I want to iterate them because the number of arguments is ...
4
votes
2answers
3k views

How to pass results of bc to a variable

I'm writing a script and I would like to pass the results from bc into a variable. I've declared 2 variables (var1 and var2) and have given them values. In my script I want to pass the results from ...
4
votes
2answers
503 views

What's the difference between root account and simulated roots?

So if I disable my root account with sudo passwd -dl root I still have access to sudo {su,bash} or sudo -{s,i} conceptually how are the elavated rights different from the root account? I know the ...
4
votes
2answers
845 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...
4
votes
3answers
128 views

To which directory should I install a program from a bash script?

I want to install Netbeans 7.0.1 with a bash script from the Netbeans website. The default directory chosen by the installer is /home/geoffrey/netbeans-7.0.1. But I do not think it belongs there.
4
votes
2answers
160 views

How to organize a block of text in 8-character lines?

I'm toying around with binary code and ciphers and I've a chunk of text which I would like to reorganise in 8-character lines (those familiar with the topic will understand why). See: ...
4
votes
7answers
7k views

Filenames with spaces breaking for loop, find command

I have a script which searches all files in multiple subfolders and archives to tar. My script is for FILE in `find . -type f -name '*.*'` do if [[ ! -f archive.tar ]]; then tar -cpf ...
4
votes
2answers
381 views

Help organizing music

I have an Ubuntu server installation set up as a media server with Subsonic in a medium sized office environment. I allow uploads from all employees to the media folder on the server. As you can ...
4
votes
1answer
14k views

Run a nohup command over SSH, then disconnect

I want to execute a script, start.sh on a remote server which runs this: nohup node server.js & Naively, I call SSH like this: ssh myserver <<EOF ./start.sh & EOF This starts the ...
4
votes
1answer
860 views

How can I set xdotool and gedit to open a document and save it twice?

I need assistance in creating a script that does the following: Open Gedit Open a document with Gedit Save the document twice Close Gedit I was wondering how can I make it happen with Gedit and ...
4
votes
1answer
3k views

Ubuntu 12.04 doesn't seem to execute my .profile file

(I'm kinna n00bish) 1: I had ubuntu 11.10 installed, then upgraded to 12.04. 2: I had a script in my .profile file to turn off my laptop's touchpad (it worked, and was executed on login) 3: Now it ...
4
votes
2answers
2k views

How to open several Terminal Tabs in different folders (working directories)?

I want one script to open several Tabs in different folders. While searching I found this entry, but an exchange like seen below did open a Terminal with three tabs in my home folder. The error ...
4
votes
2answers
355 views

Combine Two Commands In a Script

I want to put two commands together I need the script to login: ssh root@192.168.0.188 Then I need to the script to run (while logged in to root@192.168.0.188 via ssh ): find ...
4
votes
3answers
114 views

How to check the number of fields given to the `read` command?

I have a quick question relating to $# in the shell scripts. So, I can use $# at the command line to check the number of a shell script arguments given by the user. Example: # ./shellScript varONE ...
4
votes
1answer
636 views

how to resolve all symlinks in a directory?

I'm trying to make a debian package from upstream source code which is not mine. The configure script provided by author makes a lot of symlinks in source directory. They're symlinks to all headers in ...