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)

2
votes
2answers
4k 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, ...
1
vote
0answers
13 views

programmatically alter kde file associations

Problem: In kde I want to remove a particular file association from every file type Details: I wanted to try out clamTk as a companion to clamAv. It didn't suit my needs so I uninstalled the ...
2
votes
2answers
25 views

How can I copy and move a sequential subset of files?

I have a directory containing 1772 files named PRC0001, PRC002,... up to PRC1772. How can I copy a subset, for example PRC0257 to PRC1516 to a different directory? I am trying to do this for several ...
0
votes
1answer
15 views

Why do some apps leave KeyRelease events to be consumed by next focused app/window

I'm trying to wrap dmenu within some script to feed it input and act on it, however when pressing the Return key to select some dmenu input, a KeyRelease event gets sent to whatever window is focused ...
0
votes
1answer
731 views

How to execute grep in tcl for getting XYZ-123 type pattern

How can I execute this grep command in TCL? grep '[A-Z][A-Z][A-Z]\-[0-9][0-9][0-9]' file1 > file2
2
votes
5answers
192 views

cut for key-value pairs

I am looking for an easy way to cut key-value pairs (where the key is unique and specified) from text, much like how cut can be used to cut a specified column in a CSV file. The keys I'm looking for ...
4
votes
3answers
249 views

Run command automatically when files are copied into a directory

I have two folders called: A and B, in different paths on the same computer. When I add any new file(s) into folder A, I want to copy it to folder B automatically. My folders: /auto/std1/nat1/A ...
1
vote
4answers
77 views

Script to delete files that don't match certain filenames

I have a folder with 500,000 images, sorted in subfolders by year and month. I'd like to create a script that does this: If the filename does not match any of the filenames in names.log then delete ...
0
votes
2answers
35 views

script for substition incremental

I have 4 machines, every machine(centos) has a ifcfg-bond1 with identical ip address 10.0.0.3 How to using bash and sed substituting 10.0.0.3 with a incremental value? I want to obtain something like ...
1
vote
1answer
23 views

Possible to deliver centrally configured login scripts on Linux?

In Windows you can assign login scripts to users which run whenever they log into a system which allowing admins to do things like map drives/printers and generally do anything for which there isn't a ...
0
votes
1answer
54 views

bash if, then and else statement

I am learning bash, I ran into a small problem when trying to write a small script #!/bin/bash clear read num if [ "$num" -eq 2 ] then [ -d "/etc/passwd" ] | sudo cp /etc/passwd /home echo ...
2
votes
2answers
102 views

Bash menu with multiple parameters in one row

I have searched a couple of days and still didn't found the answer. I hope that you can point me in right direction. I would like to know how to write a bash script with a options, that can be ...
4
votes
1answer
103 views

print the content of files

I have a list of parent folders, sub folders and files inside the folders and the sub folders. I used the following command line to list the content of the parent folders and the sub folders: tree ...
7
votes
7answers
176 views

What is the purpose of having two variables ($@,$*) to transmit the arguments of a command into a script? [duplicate]

I have read of the special variables used in a script $@ and $*. As far as I understand, the arguments used while executing the script are stored into two special variables, once all arguments into $@ ...
0
votes
0answers
37 views

Why are some Python apps not compiled but rather distributed as scripts? [closed]

As an example, I've got Quod Libet (a music player) here. The /usr/bin/quodlibet file is a python2 script (not sure about other files it is using, coz I don't know where they are). At the same time, ...
3
votes
2answers
1k views

Programatically use visudo to edit sudoers?

I have a sudoers file stored in our svn repo. I want to svn export it to /etc/sudoers but can't do it because sudo detects that it was not edited by visudo and throws syntax errors. What exactly does ...
3
votes
3answers
4k views

Javascript to HTML converter?

Take for example this snippet of code on a web page. <html><body> <script language="javascript"> document.write("The cat"); document.write(" sat on the mat"); </script> ...
6
votes
4answers
495 views

Why is it “while kill -0 $PID” and not “until kill -0 $PID”?

I may be being daft here, but if I want to do something while a process is running, why do I do: while kill -0 $PID do #... done instead of until kill -0 $PID do #... done ? kill -0 ...
0
votes
2answers
20 views

Script to backup home directory creating a compressed tar file in the /var/local directory

#!/bin/bash tar -czvf backup.tar.gz /home/administrator Having problems with making sure the file is created in the /var/local directory.
2
votes
4answers
2k views

Is it possible to execute a VIM script in a non-interactive mode?

The Gnats bug tracker has a command (edit-pr) that opens a ticket in $EDITOR. My $EDITOR is VIM, and when this command opens the ticket in $EDITOR, I'd like to automatically perform some scripted ...
0
votes
0answers
15 views

Dual partition scheme with GRUB

I would like to use a dual partition update scheme for some servers like CoreOS is doing here. Basically the process is the following: The computer has partition A and B, each with a full Linux ...
0
votes
0answers
11 views

Modify query output in a script [closed]

I have my script check_rel.scr. Inside i have to run a query into a db. sql ${DB} < /tmp/tmp2 Just to be clear, /tmp/tmp2 is the result of other command before to run the the command above. But ...
1
vote
1answer
33 views

Saving result between script executions

I have a script in /opt which is called regularly by Cron. The script needs to write and read a status flag between executions. In what directory should I store the flag? I'm thinking that /tmp might ...
0
votes
1answer
36 views

bash: getting integer expression expected

Here is the piece of code that gives the problem: if [ " ls -l ~/sysbackups | wc -l " -gt 5] What to do?
2
votes
1answer
42 views

ssh and run script on remote host and answer expect answer automate

The ssh from server0 to (server1,server2,server3) (no password need to SSH (trust exists between all servers and private key exists on all servers)) but a remote script on server (server1,server2 ...
0
votes
1answer
49 views

Run a Vim command from a bash script

This is related to a question I asked earlier but I would like to keep it separate in case anyone else can find use in it. I have a command that I am running on a file called dummy.out from the ...
3
votes
5answers
2k views

Replacing text from a list of replacements. Added complication: backslashes

I have a file A that contains pairs of strings, one per line: \old1 \new1 \old2 \new2 ..... I would like to iterate over file A, and for each line perform the replacement (e.g. "\old1 -> \new1") ...
2
votes
2answers
55 views

Bash Scripting VIM commands

I have a few files that I have an annoyingly repetitive group of VIM commands to apply to. They are basic VIM commands just to delete some lines which are not supported by the process I need the files ...
5
votes
2answers
5k 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 ...
-1
votes
0answers
22 views

Script to generate a report from a logfile [closed]

Need a BASH/perl script to generate a report from a logfile. Below is the log file example. TIME HOST SERVICE STATUS DESCRIPTION 1 A X CRITICAL DOWN 2 A ...
0
votes
1answer
26 views

Python script: wait until job in tmux session has completed

I am trying to continuously run a python script with random parameters from another python script, where each run is in its own tmux session. A very simplified overview of what I'm trying to do goes ...
2
votes
3answers
113 views

Processing input line by line (with empty lines) from shell

In a shell script, I need to parse the output of a command line-by-line. The output may include empty lines, and these are relevant. I am using ash, not bash, so cannot resort to process substitution. ...
1
vote
1answer
21 views

Auto-start multiple background user sessions in Linux Mint

I could use some help with what I think is a basic request on the newest edition of Linux Mint (which I think would also be applicable to Ubuntu). I have a home system with 3GB of RAM and accounts ...
2
votes
6answers
90 views

Scripting to split a single CSV row into multiple

I need a script that can take a CSV file with that has a column of semicolon-delimited attributes, and break it into multiple rows to normalize that multi-valued attribute? Here is the scenario: ...
1
vote
1answer
30 views

value too great for base (error token is “08”)

Trying to do quiz 'max sum of 2 from grid' Can't figure out how to get around the error below. Feels like I'm missing something. Once I find out what I can update the question to be more general ...
1
vote
1answer
60 views

script needs to add another loop

script which runs netstat -tulpun | grep -i port_from_the_list & takes the output for running the next command I need to run 2 command on all the server mentioned in the list. server: Jan port: ...
2
votes
2answers
414 views

securely automating a script which requires a key to do its task

I have a script that downloads bank transactions to store in a database. To get these transactions requires a password for each account. The database is encrypted and requires a key to access it. All ...
1
vote
3answers
210 views

Read longest line in file using while read loop?

I've been googling but I can't find any scripts that uses the while loop to read the lines. I'm stuck and I'm not sure on where to start Heres the question: Write a bash script longestline.sh that ...
3
votes
4answers
3k views

How to capture error message from executed command?

I was tasked to create an automated server hardening script and one thing that they need is a report of all the output of each command executed. I want to store the error message inside a string and ...
2
votes
3answers
185 views

What is the purpose of a start up script? [closed]

So far I know the basic meaning of a script, it is a file containing shell-commands made executable by chmod +x file and able to be run by ./ file. My friend told me, he had to copy so called start ...
1
vote
3answers
2k views

Awk printf number in width and round it up

I need to printf a number out, but with given width and rounded (with awk!) %10s I have this and somehow I need to connect the %d but everything I do, ends up with too much parametres for awk ...
0
votes
0answers
29 views

What do i have to consider to write a script that reacts on a keypress?

I know i can read within a script something into a variable, like this: variable = read But i have to press enter in order to submit the value into the variable. What do i have to know in order to ...
1
vote
0answers
24 views

Service script and shared libraries

I have the following simple script IPN in CentOS 6.5 in /etc/init.d/ #!/bin/sh # chkconfig: 2345 05 06 cd /root/IPNHost . /etc/rc.d/init.d/functions start() { echo -n $"Starting..." ...
0
votes
1answer
64 views

How can I use a linux shell script to change directories and copy files?

There are several files I need to copy which are stored in different directories. The file names will all have two common fields that are distinctive for a particular date and time. I can usually ...
0
votes
2answers
67 views

Grep matching cell of the csv file and index of that row

I have csv file and I want to see numbers that start with 0.99 and their row's index which is the first cell of that row. This is what I have so far: cat fil.csv | grep '0\\.99'| tee > (cut -d, ...
0
votes
2answers
174 views

VLC script on ubuntu server

I need a small script which run three vlc command on the same time (on Ubuntu server 14.04) as stated below: #!/bin/sh cvlc -vvv v1 --sout ...
20
votes
4answers
5k views

Does the shebang determine the shell which runs the script?

This may be a silly question, but I ask it still. If I have declared a shebang #!/bin/bash in the beginning of my_shell_script.sh, so do I always have to invoke this script using bash ...
0
votes
5answers
50 views

How to Read string from file and compare to each line of second file

I'm making the post OS installation script that will include the Hardening section . And in this hardening section it will read the Kernel parameters from file A and compare to file /etc/sysctl.conf ...
6
votes
5answers
621 views

Modify a file without creating another file

Is there a way to modify a file without writing the contents to other file, without sed and awk? For example, $ cat test.txt aaa aaa bbb ccc ddd Replacing using sed with -i option, sed -i ...
1
vote
3answers
268 views

How can I pass on parameters 4..99 to another function

I'm calling a function and I want to pass up to 100 paramters onto another function. I do not want to pass on the first 3 params, I start with param4 being the first param for the other program. I ...