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)

1
vote
2answers
3k views

How to correctly concatenate strings in shells script?

I have a bash shell which I need to modify, and I have to set a variable in a script and then call another script. My variable, EXTRA_JAVA_OPTIONS must be -javaagent:myagent.jar="-d 0 -i 1000 -l log2 ...
1
vote
4answers
524 views

Rerunning the same command with a different parameter

I know that I can run the following command ls Some{File,Folder} And it is equivalent to running this: ls SomeFile SomeFolder (I also use it a lot for things like mv place_{a,b}) However, I was ...
5
votes
2answers
253 views

How to consistently start Vim's command line to make a mapping work in any mode?

I try to normalize access to Vim's command line mode from any other mode in order to simplify my actual mappings. For example to make the <f6> key work from anywhere I define the following ...
6
votes
1answer
333 views

How to change Vim's command type mode programmatically?

Is there a simple way to switch from one command type mode to another without loosing the current command line? In my ~/.vimrc file I remap the <space> and <c-space> character, coming ...
3
votes
3answers
6k views

Check whether files in a file list exist in a certain directory

The runtime arguments are as follows: $1 is the path to the file containing the list of files $2 is the path to the directory containing the files What I want to do is check that each file listed in ...
0
votes
2answers
174 views

fwui.log error while running this script

I run this bash script in order to put all the files with the following format dated today in the same folder. for example here I want 2012-12-17_083213 to be my folder and then inside it I have the ...
3
votes
2answers
631 views

Run shell scripts through a website

I have been reading and searching on what is the best way to run my shell scripts through a website. My goals are as follows: Browse a folder Select folder or contents onclick will run script ...
8
votes
3answers
2k views

Difference between commands in bash script and commands in terminal

Are there any differences between commands that you type into the terminal and commands you include in a script?
2
votes
1answer
229 views

Access the Shift-Insert clipboard from script

How do I access the Shift-Insert (paste) clipboard from a script? You can see what I use here. Edit: A demonstration how it works, with xclip: echo hello | xclip -selection secondary xclip -o ...
2
votes
2answers
4k views

Scripting VMware configuration: can I use PowerCLI?

I have an automated task to start, it involves various commands in PowerCLI. like Allocate Space New-Datastore Parameter(1) Browse Datastore Get-Datastore Parameter(1) Remove file ...
2
votes
4answers
190 views

store and execute redirection/piped command in script

How do you store, and later execute, a command with redirection and and a pipe? (And is it the pipe, or the redirection, or both, that's causing my problem?) I tried to print the urxvt version in a ...
7
votes
1answer
1k views

Problems running python script from motion

I'm trying to set up the raspberry pi with my webcam as a motion detecting cctv that uploads the videos to google drive using Jeremy Blythe's script I have motion working correctly and the python ...
2
votes
1answer
79 views

required output not achieved by bash script

I am new to bash script and want to create bash script that moves some days old files between source and destination as per days defined in script. #!/bin/bash echo "Enter Your Source Directory" ...
2
votes
1answer
268 views

How to set Cols and Lines for a Subprocess

I have a script that runs a series of scripts numbered 001,002,003,004... etc down to 041 right now, will be more in the future - and these scripts them selves use some cursor control to print a ...
1
vote
2answers
475 views

Bulk Adding Users to Groups

Let's assume I have a Linux box configured as a primary domain controller with 50 users connecting at any given time. If I wanted to create two groups, one called "Teachers" and the other "Students" ...
0
votes
1answer
1k views

Bash script to copy *.log files into a new directory

I have some files like this: 2012-12-17_083213_1.log 2012-12-17_083213_1.log_stats 2012-12-17_083213_1.logaccount_ptr 2012-12-17_083213_1.loginitial_ptr 2012-12-17_083213_1.logptr ...
3
votes
1answer
333 views

How to reference a script-local dictionary in a Vim mapping?

Somehow I'm not able to execute the following mapping: function! s:MySurroundingFunctionIWantToKeep() let s:Foobar={'foo': 'bar'} map \42 :echo <sid>Foobar.foo<cr> endfunction call ...
3
votes
1answer
554 views

Split file based on a pattern with leading zeros

I have a book in text format. I would like to split the book into several files where each file contains a single chapter. Therefore I'm using the following command: awk '/Chapter/{i++}{print > ...
2
votes
1answer
1k views

permission denied executing script over ssh

When a web page is loaded on server A i want it to run a script on server B. I can do this with a series of commands from server A by logging into server B and executing the script, but it needs to be ...
20
votes
1answer
1k views

How to implement a horizontal cat? [duplicate]

Standard cat concatenates files line by line (row by row, if you will). I find myself needing a horizontal cat command more and more often recently; i.e. a command that takes a list of files and ...
0
votes
1answer
100 views

why there is random behaviuor for a background job?

going through advanced bash scripting guide example 3.3 running a loop in background, i found this : #!/bin/bash # background-loop.sh for i in 1 2 3 4 5 6 7 8 9 10 # First loop. do echo -n "$i " done ...
1
vote
1answer
570 views

What is difference between POSIX and bash and other shell scripts?

While going through many answers on Unix.SE, I come across many of them writing their contents w.r.t to Posix or Bash or some other standard. I know of some differences like some have arrays and some ...
2
votes
2answers
5k views

grep output of expect script

I'm trying to run some expect language, and grep/parse the output all in one script. I want to grep the output of and look for "error" (I should note that standard linux commands like awk, sed, grep, ...
5
votes
2answers
7k views

Trouble in script with spaces in filename

I've got a script that scp's a file from remote host back to local. Sometimes the file names contain spaces. scp does not like spaces in its file names. For some reason my attempts at handling the ...
0
votes
1answer
662 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
134 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 ...
2
votes
2answers
638 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
452 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
698 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 ...
4
votes
1answer
2k 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
809 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 ...
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
611 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
13k 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
5k 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
246 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
182 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
123 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
279 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
516 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
426 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?
5
votes
3answers
626 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
3k 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
619 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 ...