A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.
0
votes
0answers
22 views
How do I comment parts of a multiline command? [duplicate]
In bash command line or scrip invocation, a command could run several liens long. In this case, delimiting the lines with \ is useful.
What I am trying to make work is:
command \
-option1 ...
0
votes
1answer
119 views
ipset not executing from crontab
I have this txt files that contains IPs, one per line of file, that I want to block using ipset.
I have this bash script that essentially reads from the plain txt file and constructs an array. Then ...
1
vote
2answers
161 views
At login, take picture of user at Login window(loginGUI promt window)
I have code to take a picture in a script. I don't understand how to run this script at the time of login. I would like to modify the login process so that:
The user gets 3 login attempts.
After 3 ...
3
votes
3answers
82 views
Where are userspace programs supposed to save their logs?
I am writing a script that I want to run without privileges. I want the errors that the script encounters to be logged to some log file. I do not not have privileges to write one to /var/log. And I do ...
6
votes
3answers
268 views
Universal Node.js shebang?
Node.js is very popular these days and I've been writing some scripts on it. Unfortunately, compatibility is a problem. Officially, the Node.js interpreter is supposed to be called node, but Debian, ...
1
vote
1answer
74 views
Running a script as Grub boot option
I'm assembling some DR stuff for my Linux boxes. One item that would be really handy would be a GRUB option that would run a script to change my boxes from static IPs to dynamic.
I know we could do ...
3
votes
2answers
69 views
Comparing two columns with two columns
I have a file that I need to compare the values in two columns with another two columns. For examples:
Item A B C D
1 201 3101 3101 201
2 3101 201 202 3101
3 3101 201 ...
2
votes
1answer
107 views
bash scripting add arguments
I have created a script which takes parameters and arguments. I want to insert the --help argument.
I already know how to parse normal arguments with -, but I don't know how to parse the -- ones.
to ...
2
votes
5answers
470 views
How can I split a text file into multiple text files using Perl?
I have a file ABC_TabDelim.txt that contains the following:
00:00:00:00 00:00:05:00 01SC_001.jpg
00:00:14:29 00:00:19:29 01SC_002.jpg
00:01:07:20 00:01:12:20 01SC_003.jpg
00:00:00:00 00:00:03:25 ...
3
votes
2answers
315 views
Iterate over multiple parameters with spaces in bash script
I have a bash script for my RaspberryPi (running Raspbian) that is supposed to take multiple file names as parameter(s) and play one after the other (using omxplayer). The basic structure is this:
...
1
vote
1answer
107 views
Open kickoff via shell/script
Is there any (undocumented) way to open the KDE Kickoff menu via dbus or some similar mechanism?
1
vote
1answer
129 views
How to match 2 large file and print the difference in shell script
I have 2 files.
File1 has 400k numerical records.
e.g:
1
2
3
4
5
6
.. and so on
File 2 also has 420k numerical records.
e.g:
1
2
3
4
6
.. and so on
Both these file are in unsorted manner. I want ...
2
votes
2answers
215 views
System calls, AWK, and Bringing in external inputs
awk '{ TEMPVAR="/usr/bin"; printf("%s", system("ls $TEMPVAR")); }' empty
In this example I'm trying to bring in the variable TEMPVAR into the system call. How would I do this?
What I'm aiming to ...
10
votes
2answers
287 views
Shebang line with `#!/usr/bin/env command --argument` fails on Linux
I've got a simple script:
#!/usr/bin/env ruby --verbose
# script.rb
puts "hi"
On my OSX box, it runs fine:
osx% ./script.rb
hi
However, on my linux box, it throws an error
linux% ./script.rb
...
2
votes
2answers
422 views
If Statement with 2 Variables - Bash
I am trying to write a single IF statement which can check two variables at once.
I have two variables, for example:
$VARA
$VARB
Both with either contain a 0 or a non 0 value. I need an if ...
24
votes
7answers
1k views
What's the equivalent to && when writing a bash script?
I apologize in advance if this is a duplicate question. I did make an effort to search/check before asking here.
I'm comfortable with writing one-liners like this:
foocommand && ...
4
votes
3answers
110 views
bash -e exits when let or expr evaluates to 0
I have a bash script that sets -e so the script will exit on any exit status != 0.
I'm trying to do some basic shell arithmetic assigned to variables and sometimes the expression equals 0 which ...
3
votes
1answer
76 views
Issue when setting a default path in BASH
I have a BASH scripting question. I'd like the mention that I am new to BASH scripting; however, I am not new to programming. I am developing a simple BASH script to watch a given compass project. My ...
4
votes
3answers
128 views
Why can't I source a script file from .xsessionrc?
I am running LXDE/Openbox on Debian Linux. On logging in I want to:
add a user specific directory to the $PATH variable (A)
execute some (non-graphical) commands (e.g. mount directories) (B)
The ...
2
votes
2answers
228 views
Averaging output of dstat
I need to average upload and download speed using dstat -n. How can I add all the received and sent data sizes that appear after dstat -n, so that I can add them and find average upload and download ...
1
vote
2answers
178 views
How to use an optional argument?
I'm writing this script to work as a fast draft. It opens my text editor with date and time, so I can insert some draft text to save quickly.
1. At first I'd like to append the date and time at the ...
0
votes
1answer
85 views
How do I write a script to keep retrying Yum Update Program?
My job let me always release a new version of the program to a satellite server, then in the running server, I use yum update program to update the program.
However, due to unknown reason, in most of ...
5
votes
4answers
251 views
Testing, from a script, if audio devices are in silent?
Is there a default program where I can check if my audio devices are in silent?
Edit: By silence, I mean that if there is something playing on that (not just activated or opened)
Something like ...
3
votes
2answers
233 views
Determining if a host is online
I'm testing stability of a machine and I need way to simply write a Bash script to determine if a host is online or not. How could I script this?
if [ ! $(hostisonline) ]; then
# profit
fi
1
vote
1answer
88 views
Frequent command “template”: remove parameter expansion escape characters
zsh newbie here... I find myself using a handful of long commands over and over again with slightly different arguments. For example:
rsync -havu --progress --rsh='ssh -l mylogin' ...
2
votes
2answers
115 views
Script to choose editor to open file based on the argument
I'd like to run my script fastex with two possible arguments (g or t), like fastex g.
Based on the argument I want to call geany $file or texstudio $file. This is to choose the editor.
I tried
...
1
vote
2answers
299 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
3answers
104 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 ...
2
votes
2answers
98 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 ...
2
votes
1answer
103 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 ...
2
votes
2answers
263 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
78 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
280 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
...
6
votes
3answers
399 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
127 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 ...
1
vote
2answers
328 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
114 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
216 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
70 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
60 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
74 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
459 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
...
1
vote
1answer
59 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
158 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
187 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 ...
16
votes
1answer
503 views
How to implement a horizontal cat?
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
73 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
127 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 ...
1
vote
1answer
457 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, ...
2
votes
1answer
178 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 ...

