A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

learn more… | top users | synonyms (2)

7
votes
2answers
4k views

Semicolon in conditional structures

Why put semicolons in one and not in another? The result is the same Code one if [ "a" == "a" ] then echo "true" fi Code two if [ "a" == "a" ]; then echo "true"; fi Semicolons in the second ...
4
votes
2answers
161 views

Dealing with script interruption

I need to iterate over between 120k and 500k files. find handles this well. find $PWD -type f -path "fragments/*.pdbqt" For some reason I want to list the same set of files again, in the same ...
31
votes
3answers
17k views

What does it mean to have a $“dollarsign-prefixed string” in a script?

I just saw this in an init script: echo $"Stopping Apache" What is that dollar-sign for? My research so far: I found this in the bash manual: extquote If set, $'string' and ...
2
votes
1answer
1k views

How do I get simple scripts which seem to need root priveliges to run via the www-data user?

I am programming a small webinterface to control samba on Debian (kernel 2.6.32-5-686). I started by writing simple scripts to add users, create folders, etc. They worked fine when run as root. ...
2
votes
1answer
668 views

Parsing SQLite output

Using -line Option I get this output from SQLite: row1_column1 = valueA row1_column2 = valueB row2_column1 = valueC row2_column2 = valueD So one line for each column value and result rows are ...
2
votes
2answers
540 views

Import single rows from SQLite to MySQL?

I need to do some kind of incremental import again and again from a SQLite 3 database to a MySQL database. Column names are the same in both databases. Is there a good way to do this by a script ...
1
vote
2answers
910 views

What scripting language or platform to use for web page downloads and screen interaction? [duplicate]

Possible Duplicate: Does anybody here have experience in automating some tasks in web applications using curl? Here is what I need to do? Wondering what platform is most suited - easy to ...
1
vote
1answer
684 views

Error QProcess: Destroyed while process is still running

Edit: I discovered that the problem is not related with the script cited below, but I'll leave it there just for history. Well, this error appears when I close texstudio with the viewer open (xdvi or ...
0
votes
1answer
767 views

Script with root permission [duplicate]

Possible Duplicate: Redirecting stdout to a file you don't have write permission on I am creating a script to change the brightness of my laptop. I discovered that I can do this using ...
4
votes
2answers
17k views

Execute shell script from php, as root user?

Need to execute the following line from PHP: $res = shell_exec('sudo sh /home/nicklas/cronjobs/make_account.sh username password'); The problem is nothing happens on execution. If i try to ...
1
vote
1answer
236 views

TeXstudio: open file at line number n

I am creating a script to produce some .tex files with a lot of lines (a kind of automatic sample). The script finishes with texstudio /home/$USER/foo.tex where foo.tex is the file created before. ...
6
votes
1answer
720 views

Can capabilities be used in scripts without setcap'ing the interpreter binary?

Right now I'm using cap_net_bind_service MY_USERNAME in /etc/security/capability.conf. Now I just need to set cap_net_bind_service+i on the interpreter of my favouite scripting language to be able to ...
4
votes
4answers
912 views

How useful is Linux scripting? [closed]

I am a beginner user of Linux and have worked primarily with GUI. I am trying to move to intermediate level by learning the shell commands. In online Linux forums it's often the consensus that to be ...
7
votes
5answers
5k views

Check if script is started by cron, rather than invoked manually

Is there any variable that cron set when it's running a program ? If the script is running by cron, I'll skip some parts; otherwise invoke those parts. How can I know if the bash script is started by ...
1
vote
1answer
158 views

Using join with two files fails on larger file sizes

I am having some issues with a script that is using join to join two files. Eaxmple input files contains lines like this: Here are the input file and the output of the join command: ...
4
votes
4answers
4k views

How do you colorize only some keywords for a bash script?

I am running some unit test code. The unit test code outputs regular text. There is a lot of the text so I want to highlight for the user important keywords. In this case the keywords are "PASS" and ...
15
votes
4answers
23k views

How can I use bash's if test and find commands together?

I have a directory with crash logs, and I'd like to use a conditional statement in a bash script based on a find command. The log files are stored in this format: /var/log/crashes/app-2012-08-28.log ...
3
votes
1answer
219 views

Locking in a shell script

I want to write a long-running shell script so that only one copy could be run at a time. If the script crashes, I want a new invocation of the script not to be stopped by a lock from the crashed ...
2
votes
0answers
186 views

How to emulate a KWin effect by command line?

I would like to apply the Toogle Invert Effect when I start my system. So, I need to know how to call this KWin effect using the terminal. OBS.: I'd tried xte "keydown Meta_L" "key i" "keyup ...
1
vote
1answer
772 views

Selecting icon for tray notifications from Bash scripts (KDE)

Q: How to make Qt KDE tray notification from Bash script ? A: @SO: Activating KDE 4 notifications from bash scripts Q: How to make notifications from scripts running as root ? A: @Unix.SE: Show a ...
3
votes
3answers
310 views

How to make and apply (patch) one side diff?

I want to make a shell script that updates a config file. The file present on the server has information, like various IP addresses. The new file has more code, from new configs added to the system, ...
4
votes
1answer
98 views

Transform directory structure

I have the following folder structure root folder |-al2 |- GER.zip |- ENG.zip |-ww |- GER.zip |- ENG.zip and so on. The folder names are random strings. I want to sort the files in ...
1
vote
1answer
508 views

How does “options” in shell scripting work?

I found some code in one of the answers here and accommodated it to my needs but now I have two questions: Q1: how can I display the options text after the code in case statement finishes? So the ...
2
votes
3answers
1k views

Copy/backup all dirs containing files matching a regexp

I would like to do a backup where I recursively go through a dir structure and only get directories with files whose names matching a particular regexp. I would like to keep the directory structure, ...
2
votes
2answers
863 views

What would it take to add a command to run a script at the completion any given random task?

I was playing around with Pushover, and had the thought that it would be cool if I could use it as an argument on any random command, so that it would run a pushover script at the end of the task, ...
0
votes
1answer
4k views

Automating excel report

Could you please help me for the below concerns. I'll be executing one script which gives some output Have to arrange them in a table format in excel Attach the excel and send it through mail ...
14
votes
1answer
4k views

Making a progressbar with “dialog” from rsync output

I'm looking for a way to filter/redirect rsync output in a manner where it can be fed to the "dialog --gauge" command, so I can get a nice looking progressbar during file sync. Currently I have only ...
6
votes
2answers
3k views

assign shortcut key to run a script

I've written a script to change the brightness of my screen. It's useful when I am working on text mode and shortcut keys of my keyboard to change brightness doesn't work. Is it possible to run this ...
3
votes
3answers
5k views

Shell Script to Execute Shell Script to All Subdirectories

I am making a script to simplify my daily tasks. Everyday, I have to grep for a few things inside a company server. It was okay, however, now, they have segregated each object into sub directories. I ...
0
votes
1answer
223 views

Bugzilla email_in.pl script will take 111 hours to complete - how can I change that?

I have an old Bug tracking system, with about 20k bugs. We have installed a new bugzilla system, and part of the initiation will be to import all the bugs from the old system to the new. I am able to ...
5
votes
1answer
1k views

Which command will open the default browser on a system to a given web page (terminal)?

Title says it all. Is there a way to open the default browser on a user's system to a specific page from within a Bash script, or other-language script?
0
votes
2answers
164 views

HDI script fixed (non-interactive) input in a command-line gui program?

I want to create a simple script that initiates a simple gui-based program (think ncurses-style, text-based graphics in a shell) in Debian. I only access the server through SSH, so I can't do ...
13
votes
4answers
27k views

printing colored text using echo

I know that for printing a colored text using echo, for example red color, the code is: echo -e "\e[1;31m This is red text \e[0m" and I know that in this example, 31 is code of red color and the ...
4
votes
3answers
7k views

Execute remote script with local parameter value

How can I automatize this task? 1) You are at A. 2) You ssh into B. 3) You run a script at B, that needs a parameter known at A. First, I thought perhaps I could send the value when I opened the ...
2
votes
1answer
266 views

How to add variables to script output?

A program to calculate statistics outputs its data in this format Calc_Statistics -input_data ...
5
votes
2answers
722 views

How to parse many variables to bash?

A program outputs its data in this format: n=4607356 null_cells=5668556 cells=10275912 min=0.0433306089835241 max=0.53108499199152 range=0.487754383007996 mean=0.40320252333736 ...
6
votes
1answer
789 views

Peculiar piping grep/head behavior

I'm helping the netadmin here with a perl regex to automate operating on some snapshots from our SAN and our scripts does stuff like this: varinit1=$(iscsiadm -m session | grep rbmsdata1 | head -n1 | ...
3
votes
2answers
891 views

is there any command like “wall” that runs a “command” in all terminals

as you know "wall" command sends a message to all terminals: wall message now my question is this: is there any command that can send a "command" to be run in all terminals? for example sending ...
4
votes
2answers
368 views

Exiting a pipeline if a former command fails

I'm trying to check the number of running and queued PBS jobs by parsing the output of qstat -tn1 from a bash script. So far, this has worked: count () { qstat -tn1 | awk ' BEGIN { R = 0; ...
4
votes
4answers
4k views

cut / grep and df -h

How can I grep or cut the "173G" under "Verf"? I need this for Unix scripting in school. jonas@jonaspc:~/$ df -h /dev/sda2 Dateisystem Größe Benutzt Verf. Verw% Eingehängt auf /dev/sda2 ...
0
votes
2answers
2k views

Re-assigning (specifically, incrementing) a variable in a bash script [duplicate]

Possible Duplicate: How can I do command line integer & float calculations, in bash, or any language available? I would like to simply re-assign a variable (to be specific, increment it ...
1
vote
4answers
600 views

Is learning a text editor like vi necessary and still worth the time today? [closed]

I started a new internship where all the servers run on AIX. Logging in for the first time I was suprised to see that my favorite text editor nano was not installed. Everyone here uses vi not ...
2
votes
4answers
3k views

chown all files based on file name pattern in current directory

I'm trying to chown all files whose filenames begin with ChownFileNames. I've used this command, but it doesnt seem to work: find . -maxdepth 1 |grep 'ChownFileNames*' -exec chown hadoop:hadoop -- {} ...
1
vote
2answers
640 views

Bash script to ftp only files of type gz in current directory

I have a bash script that cd to the right directory then uses the mput command to ftp all the files in the directory to a remote server, as below: for from_dir in $DATE_LIST do cd ...
4
votes
1answer
618 views

KTorrent: Moving data in a shell script

I'm trying to make a script for my magic folder that will move files to a seeding directory without KTorrent losing track of where the data is, similar to the "Move Data" context menu action in the ...
2
votes
4answers
3k views

Loop with 2 variables in a bash script

I am trying to utilize an API. I need to either do some type of "for loop" that replaces or utilizes 2 variables... In pseudo.. # Declare New Servers newserver=( box001 box002 box003 box004 box005 ...
3
votes
2answers
6k views

How can I trim the carriage return from text that is being piped in bash?

I'm using this command to get my last typed command: history | cut -c 8- | tail -n 2 | head -n 1 It works very well in bash, removing the line numbers, but there is one problem I have with it, (er, ...
4
votes
3answers
1k views

In linux, would it be possible to run a script every day 3 minutes later than the previous day?

My first solution to this was to execute date +%Y%m%d%H%M and put that format of numbers into a file, and run the script every minute from cron. Then if the date from the file matches the date ...
2
votes
2answers
304 views

Quick and dirty way to run a process more than once

I am looking for very simple bash script that would allow me to launch a process a few times. What's essential to me is that after the processes terminate, everything will clean up automatically. ...
1
vote
2answers
144 views

How to parse fields out of a text file and write them to another file

I have executed a database command and have generated an output file of the results. Each field name starts with dbt_xxxxxx Each field value is the value after the equal sign. how can I parse the file ...