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 (1)

0
votes
1answer
558 views

Unix cp wildcard with directory structure [duplicate]

Possible Duplicate: How can I copy a subset of files from a directory while preserving the folder structure? I have a bunch of directories like this: /Artists/Example Name ...
1
vote
3answers
131 views

Script to insert line into files in sub-dirs

I have a sub-dir tree with varying number of branches and most of the branches contain .cpp files (many of them). I have a header-file at the root of the tree that I want to have as a #include ...
1
vote
2answers
549 views

How can I find matches with sed (or similar) for configuration parameters?

I'm pretty good at using php's preg_match (and similar) commands, and I'm also pretty good with regular expressions, but I don't do very well with sed. I have two shell scripts I'm working on and I'd ...
4
votes
4answers
425 views

List any file ending with .in and corresponding .out with shell script

I have a directory full of files ending with different extensions, how would I list/select only the files ending with .in and corresponding .out that share the same basename? e.g. file1.txt file1.in ...
1
vote
2answers
1k views

“PING” an AP to see if it's alive? (Before associate with it)

I would like to detect if a certain AP address is alive, i.e. by "PING" its SSID or MAC address (both known). What program can I use to achieve that? I'm making a simple script that run as root. (I ...
1
vote
2answers
4k views

how do I run a cron job with a specific user?

My cron and scripting skills are very poor, but I need to run a job every 5 minutes by user 'cpc'. So I created a script and left it at /root. My crontab -e entry about it is: 0-59/5 * * * * ...
2
votes
1answer
2k views

Email picture attachments as inline along with the email body

I'm right now working with a script for emailing attachment (.png pics). Since I'm using mutt command with -a option, the email is sent as a mail attachment. I want these .png pictures to be mailed ...
2
votes
1answer
2k views

Script to get file from SFTP and run it

We have 5 servers running our code: A, B , C, D and E. From a local machine, we sftp the file to A. Then ssh id@A su - applicationname sftp id@A get <file> bye tar -xzf <file> logout ...
2
votes
2answers
621 views

How to traverse a file and extract words using their index?

The given file must not be stored in variable and then traversed due to memory size restrictions: Example: var=$(cat FILE) for i in $var do echo $i done How do you traverse all strings in a file ...
3
votes
1answer
1k views

intersection of two files according to the first column

I have two files in file A, there are sequence_numbers in the other file B, there are many columns, and the first column is sequnce numbers, I want to get a files with all the lines in the B with the ...
2
votes
0answers
734 views

Cron file syntax checker/validator script

Does anyone know a script (bash, perl, php ...) to validate the syntax of crontab files? I found this http://www.intuitive.com/wicked/showscript.cgi?053-verifycron.sh but just Vixie cron notation is ...
1
vote
0answers
175 views

Having problems with script and redirecting input to stdin [closed]

EDIT: found mistake, it was actually bug in my program, I had > instead of >= in my for loop that reads coefficients. I'm fairly new to linux, and I need help with bash scripting. I have C program, ...
2
votes
2answers
2k views

Concatenate multiple files under subdirectories

My directory structure is given below x:\Project_2012-158A\Sample_4041 SampleSheet.csv 4041_CGTACG_L002_R1_001.fastq 4041_CGTACG_L002_R2_001.fastq 4041_CGTACG_L006_R2_001.fastq ...
1
vote
5answers
2k views

Checking if a file exists in several directories

I've been working on this far too long and need some help. I need a script that will look at files in a directory and see if it exists in one of several directories. I need something like this: for ...
1
vote
2answers
573 views

Synchronize the files from One folder of a Server to other

I need a script in which Files of One server will be copied to other folder of another server ONLY AND ONLY IF the file on SOURCE SERVER file doesn't exist on DESTINATION SERVER. Further Detail ...
1
vote
1answer
1k views

Extract binaries from pcap using command line (script)

As the title says, I'm looking for a way to extract binaries from PCAP's using the command line. I realize it is possible using Wireshark -> File -> Export -> http objects etc. But tshark doesn't seem ...
5
votes
4answers
11k views

How to send multiple commands to sftp using one line

The following command sends one command to sftp using one line: sftp -o PasswordAuthentication=no user@host" <<<"lcd /home" How to send multiple lines to sftp using one line. Is there a ...
8
votes
3answers
4k views

End sox recording once silence is detected

I'm writing a script that uses sox to record me talking. Now I need sox to wait until it detects sound before it begins recording, and I do have that figured out. But I also need sox to exit once ...
4
votes
4answers
231 views

“Virtual” shell, ie. jailing an user inside a process after the (SSH) login

The title might not say much about the issue at hand so let me get straight to the point. Let's assume I have a casual user who can log in to the system via SSH into a bash shell. I also have a PHP ...
4
votes
2answers
171 views

Make ls distinguish scripts from binaries in output

Is it possible to make ls distinguish executable scripts from actual compiled binaries? The permissions are most often the same (+x), and with ls -F you get an asterisk suffix (*) for both, so it's ...
3
votes
0answers
122 views

tab-expansion and “./” bash shell [closed]

Maybe someone here would be able to help me out. Have installed Ubuntu 12.04 LTS (kubuntu) on two machines. The .bashrc and .bash_profile files are identical as the file structures on each machine is ...
4
votes
1answer
263 views

vim auto complete custom list

I had these two questions about this function " how do I load a file into a list here? " set some variable func! CustomComplete() " and then read the variable here so that b:list = a \n split ...
3
votes
2answers
460 views

How do you automatically elevate an automatic task to root privileges or is there an alternative approach?

I'm trying to write, in essence, an automatic deployment script for use by our development team and I know I can set up SSH to use keys so that I can automatically authenticate via key instead of ...
2
votes
1answer
381 views

How to capture text formatting in bash?

The following shell script works but removes colored formatting generated by rspec: #!/bin/bash OUTPUT=`rspec` echo "$OUTPUT" How to preserve the colors?
4
votes
1answer
505 views

How can I script the creation of a single partition that uses the entire device?

I am specifically using this to partition and mount EBS volumes on Amazon EC2 instances, but really this should be generally applicable to initializing any new drive. As the question says I want to ...
2
votes
2answers
2k views

Fetch values from plist file on Linux

I have bash script which was written for OS X and now ported to Linux. I don't have access to the Linux box. The bash script would read values from plist files using the defaults read and PlistBuddy ...
2
votes
1answer
592 views

Execution time of pi calculation in shell scripts

I have to run a couple of command lines on a shell script on Ubuntu, one of those is a pi calculation. It works fine when i run it on terminal via the following cmd line: time echo ...
0
votes
1answer
1k views

/bin/sh: ./check-dependencies.pl: not found — but check-dependencies.pl exists!

I'm trying to build Moses, but when I run make I get the following output: minakshi@minakshi-Vostro-3500:~/Desktop/working-dir/moses/scripts$ make release # Compile the parts make all make[1]: ...
1
vote
1answer
836 views

bash script select menu

I've many notes gleaned from the web and have written bash scripts to manage them. I've some scripts working that depend on select to make menus. Question: in a nested menu context, is it possible ...
1
vote
2answers
468 views

Get directory that script was called from

I have a script doSmth in /usr/bin. Is it possible to print the directory the script was called from is printed out by the script? So If I call doSmth from /home/me the output will be /home/me.
2
votes
2answers
561 views

Parse apache logs to exclude IP ranges

I need to look for some requests in a huge pile of apache logs. My only requirement is this: I need to only view the requests coming from any IP address that is NOT included in a list of 50 IP ranges ...
0
votes
2answers
358 views

Why does this fail as crontab but works as script [duplicate]

Possible Duplicate: What’s wrong with these two cron job’s? I want to print a formatted output from a file containing lines of date, time, long number, and long number. I set LC_NUMERIC to ...
2
votes
3answers
340 views

What is the difference between ./script and . ./script? [duplicate]

Possible Duplicate: Using ‘.’ to execute files in bash I was trying to figure out how to export my environmental via script instead of changing my .bashrc file. I found this old useful ...
0
votes
1answer
251 views

How to effectively use bash scripting (different cost reductive ways and good habits)? [closed]

This is one of the most perennially important questions. How to effectively script ? What are the bad ways and what are the good ways ? I know of some, which i will point out here. If anybody does ...
3
votes
1answer
605 views

Open url and fill form automatically

I'd like to create a script to open an url and fill some forms. I don't want to save the form data on the browser, so I think that this script would be a good solution for me. Any help? I know how ...
4
votes
4answers
9k views

Need a loop to sleep for a fraction of second

On my machine I need to execute a cycle that iterates 1 simple command that must have a delay expressed in fractions of second. Let's say that I need: to save a file with an increasing enumaration ...
2
votes
1answer
489 views

Script for courier maildir folders on CentOS LAMP environment

I'm looking for resources to help me build a script to do monthly maintenance of maildir folders for a typical CentOS LAMP VPS hosting environment. I would like to run a script that runs from a ...
4
votes
1answer
246 views

detect if key is pressed from script

I would like to detect if a key is being pressed when running a script. I have the following script: #!/bin/bash sleep 0.5 xte 'str sometext' I run this script using a shortcut to paste "sometext" ...
1
vote
2answers
156 views

Login to super user for running script

I have sample.sh script in /u01/dump location. I'm running it from root. My requirement is while running the sample.sh script it has to be login as oracle1 user using SU (super user) and display all ...
2
votes
1answer
205 views

How do I ensure outbound TCP/IP traffic always uses a VPN, even when using Wifi?

I'd like to ensure that my VPN is started and running, before any TCP traffic from any of my background services send or receive data. How can I guarantee that this is the case? How do I handle ...
1
vote
1answer
994 views

How to manage getops argument assignation

This is my first question. I'm trying to make a small script with options and I'm using getopts to do it. The weird thing is: The argument don't get assigned to the variable or it always enter the ...
2
votes
1answer
497 views

Download file linked in MySQL DB, extract text and insert into db with bash script?

I want to download a file (only download if the url ends with a certain string), which URL is in a MySQL database, extract the text and write the text to the database, by replacing the url. And this ...
0
votes
1answer
737 views

Shell script to recursively grep data from certain files in the directory and return values to file [closed]

I am making a simple shell script which will minimize the time I spend in searching all directories under a parent directory and grep some things inside some files. Here's my script. #!/bin/sh ...
2
votes
2answers
892 views

Quickly check whether many network hosts are up-and-running

Objective: check if a host is up-and-running on the network, with a method that can be efficiently parallelized over many hosts. Emphasis on a QUICK turnaround of the check. Reason to emphasise ...
7
votes
1answer
377 views

How can I tell if xscreensaver has my screen locked?

I'm thinking through alerting stuff, and decided that, if my screen is locked, I'm not there so I should push the alerts to my phone. But, I cannot currently tell if the screen is locked. I could put ...
19
votes
8answers
3k views

The most universal scripting language for Linux is?

We are writing scripts for Linux systems, there has been some debate over what would be the most universally Linux present scripting language to use. Bash, SH, Posix? What?
7
votes
2answers
2k 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
160 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 ...
23
votes
3answers
14k 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. ...