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)

1
vote
2answers
65 views

Make Trickle get the correct $PATH

Trickle is a bandwidth limiting program. I have the following script for trickle. #!/bin/bash echo $PATH trickle -s -t 3 -u 200 -d 200 "$@" I have a script in ~/bin/ that want to run the script ...
2
votes
1answer
2k views

curl and grep commands output into a new variable

I am extracting information from a website. I designed the code in VBA and found that it is taking too long to execute. So, I have decided to rewrite the code in Unix script. I am extracting a page ...
1
vote
1answer
145 views

What's the safest way to pipe an email to a script via procmail?

I have a simple procmailrc recipe that hands mail off to a script: LOGFILE=/home/foouser/procmail-log VERBOSE=yes MAILDIR=/var/spool/mail/foouser DEFAULT=/var/spool/mail/foouser SHELL=/bin/sh ...
2
votes
1answer
61 views

Why does AWK not like dots in one of two substitutions?

I'm trying to use AWK in a bash script to look for a placeholder string in a template file and replace it with the contents of a variable that (can) contain various special characters. Example: ...
2
votes
2answers
3k views

Use awk to split line into array and use that array's values in calling shell

First of all, my apologies for the somewhat clumsily worded title. If you can think of a better one, please feel free to edit. [EDIT: done] What I am trying to do is use awk inside a bash script and ...
-3
votes
1answer
75 views

why does the dollar sign cause this command to be executed?

test_script.sh: #!/bin/sh D1="$(dirname $0)" echo $D1 D0="(dirname $0)" echo $D0 What I type on the command line: $ ./test_script.sh Output: . (dirname ./test_script.sh) What significance ...
1
vote
2answers
1k views

How to check if string starts with value containing #, tab, and maybe space?

In my bash script, I want to check whether a string starts with # modified: or # new file:. In both instances, the character after # is a tab. In the latter instance, the character between ...
4
votes
5answers
1k views

Using $? in an if statement

function foo { (cd $FOOBAR; <some command> if [$? -ne 0] then echo "Nope!" else echo "OK!" fi ) } I am trying to write a function like the one above and place ...
0
votes
1answer
230 views

Can I use an if statement to detect if bash and dash are being run interactively? [duplicate]

After looking around for a while I've found several good pages describing how to check and see if a bash script is running interactively and there seem to be several methods, but one of them that I ...
5
votes
1answer
86 views

Is there any guarantee that /usr/bin/env will exist?

Often I will see scripts begin with a shebang line that uses #!/usr/bin/env interpreter_name for whatever interpreter, with the rationale that different systems might have the interpreter that they ...
2
votes
2answers
102 views

How to split files with common prefix in bash

I have a directory with many files with common prefix, like gsc*_other.foo, where * is a character that goes from 0 to 9 or a/b (where a stands for 10 and b for 11). My goal is to create text files ...
2
votes
3answers
39 views

setting up script in a linux machine for scientific computation [closed]

I'd like to setup machine for test some computation in my old laptop, before replicate the tests on the server. The computation will be image-processing and machine learning, run some program, load ...
0
votes
1answer
506 views

How to execute Netscaler commands through a remote machine via SSH connection

I have been trying to execute some NetScaler commands like "bind" & "unbind" through a Linux Box via an SSH Connection. Now the Problem is, Manually we are able to enter & execute commands on ...
2
votes
2answers
84 views

Using Sed with Regex

I would need to edit the values in a file delimited by colons (:) I would like to replace the contents of the file by using regular expression. After a grep to confirm that the item exist in the file ...
1
vote
2answers
50 views

Is this an array?

I'm currently looking at an existing script that have something like this: variable='val1 val2 val3 val4' Is this another way of setting an array? If not, what is it?
5
votes
3answers
1k views

Using notify-send with cron

I am using Arch Linux with KDE/Awesome WM. I am trying to get notify-send to work with cron. I have tried setting DISPLAY/XAUTHORITY variables, and running notify-send with "sudo -u", all without ...
3
votes
2answers
802 views

Human readable dmesg time stamps on OpenWRT

The output of dmesg shows the number of second+milliseconds since the system start. [ 10.470000] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver [ 14.610000] device eth0 entered ...
1
vote
4answers
602 views

Bash Script to Sort Files into Alphabetical Folders on ReadyNAS Duo v1

I have an old ReadyNAS Duo v1 (Sparc) running an unknown flavour of Linux. I have a folder structure with 1,000+ files I want to move into a folder structure based on the first letter of the file ...
5
votes
4answers
161 views

Prefixing and appending blocks of text to a list of files

I'm trying to prefix and append blocks of text to a list of files. Here is where I am so far. The sticking point is the sed -i "1i \$prefix" "$file" && line. sed won't substitute the value of ...
-2
votes
1answer
104 views

automatic capturing top output by cronjob CENTOS 6.5 x86_64

I have this command: top -n 14400 -a -b -d 1 > /toplogfile.txt I want to make a script which is run by cron every day to capture top output, and if it is possible gzip the output file after the ...
1
vote
1answer
65 views

Bash: show prompts if arguments weren't provided

What is the best way of supporting in the script prompts and arguments at the same time? I want to show prompts if arguments weren't provided. Is there something better/shorter than this? ⇩ ...
4
votes
1answer
223 views

Bash is automatically reloading (injecting) updates into a running script upon saving it: Why? Any practical use?

I was writing a bash script, and happened to updated the code (saved the script file to disk) while the script was waiting for some input in a while loop. After I returned to the terminal and ...
1
vote
2answers
406 views

Bash script to adjust brightness when battery unplugged

I am trying to set up my system and to get some practice with scripting and the like. I am running Linux Mint 16 on a Samsung RC520 laptop (Linux 3.11.0-12-generic x86_64). I want to implement a ...
0
votes
0answers
91 views

Video tools for creating presentation

I have captured video (with audio) from presentation, slides (just images), and array of times (when slides was listed). Goal is to create presentation video: big slide with small video frame at the ...
4
votes
0answers
83 views

GRUB 2 scripting: convert device name in GRUB notation into a Linux device name

I'm trying to use partition labels (or UUIDs, that does not matter) to select root partition without use of an initrd/initramfs. With initramfs, this is fairly easy: root=LABEL=... or ...
1
vote
1answer
123 views

Number of cores on FreeBSD

What would the equivalent of Debian's nproc be in FreeBSD? I'm trying to include this in a bash script variable so if it could just print out the number of cores that would be fantastic.
0
votes
3answers
448 views

How to compact a chmod UNIX command

Is there anyway to compact the follow UNIX command: chmod 755 scriptA.ksh | chmod 755 scriptB.ksh | chmod 755 scriptC.ksh | chmod 755 scriptD.ksh The above command makes every KornShell (ksh) ...
9
votes
3answers
557 views

Send email written in markdown using mutt

Sometimes I need to send a fragment of code on google-group inline. Text does not help here; I can type it in markdown, convert it to html (using pandoc etc.), attach to mutt as text/html and send it. ...
2
votes
0answers
60 views

Automating startup tasks

I have a "morning ritual" that occurs on every boot of my machine: starting up a few browser tabs, starting up skype, starting up terminator and subdividing some screens, etc. Is there any tool that ...
2
votes
1answer
1k views

Linux - Sending a command to a screen through a shell script? [duplicate]

I'm trying to figure out how to make a script that will be able to send commands to a screen that will execute within whatever the screen is doing. Is this possible, and if so, how is it done? I've ...
1
vote
1answer
78 views

Linux - How to open a console and display command results on startup?

I have a Linux server with a screen always displaying the end of a very usefull file. How could I automatically enter a shell and display the end of this file when the server starts? I'd like to do ...
1
vote
1answer
347 views

How can you run a script triggered by a joystick input?

I'm using a Raspberry Pi running Raspbian to power my arcade cabinet. I want to shut the Pi down using the sudo poweroff command without using the keyboard. I'm thinking the best way would be to ...
19
votes
5answers
7k views

Using while loop to ssh to multiple servers

I have a file servers.txt, with list of servers: server1.mydomain.com server2.mydomain.com server3.mydomain.com when I read the file line by line with while and echo each line, all works as ...
2
votes
1answer
804 views

permission denied on scripts in ~/bin

I set some additional locations to the PATH environment variable in my ~/.bashrc so that these are included/sourced in logins and non-interactive scripts that are scheduled with cron. I've noticed ...
0
votes
3answers
85 views

Copying specific text from one file into a schema

I have two files. One being a schema, and the other a list of data. The schema looks like: line_name: shot_edit: channel edit: cable_edit and repeats regularly for the number of lines that I ...
3
votes
2answers
1k views

How can I print only certain commands from a bash script as they are run?

I have a bash script with various if statements based on command line arguments I pass in when calling it. Having some kind of output as to what commands are being run is helpful to confirm the flow ...
1
vote
2answers
300 views

How can I make awk on Busybox treat the entire input with NULL character in between as a single record?

I wrote a base64 encode script for my Busybox system. #!/bin/sh base64encode() { /usr/bin/awk -- ' function asc(char,l_found) { l_found=0; for (i=0;i<=255;i++){ if ...
6
votes
1answer
584 views

apt-get install without debconf prompt

I would like to install chef via apt non-interactively, but by default, apt installation brings up this prompt: Is there a way to skip this step during installation or pass a value to apt install? ...
0
votes
2answers
239 views

Convert perl script to bash

The following script it's about monitoring some logs, the $timestamp is at log at every line that something happens. Example: 03:19:13.4 Begin summary update for ...
1
vote
1answer
92 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 ...
3
votes
3answers
1k views

Understanding boolean operators in bash script

phone_missing=false echo "missing $phone_missing" if [ ! $phone_missing ] then echo "Lost phone at $readabletime" $phone_missing=true fi I just can't wrap my head around this, as ...
1
vote
1answer
92 views

How to script this task?

First of all, I can make basic use of the linux command line, but have slim to none experience with shell scripting. What I want to do: I have a router running OpenWRT, a destop pc and an Android ...
1
vote
0answers
32 views

script works fine on client machine but doesnt work in nagios

purpose: nagios check for kannel stuck Date : dec 8, 2013 /etc/init.d/kannel status | grep -i -E "SMS: received" | awk '{ print $3 }' > kannel_temp_1.txt /etc/init.d/kannel status | grep -i -E ...
6
votes
4answers
1k views

Intersection of two arrays in BASH

I have two arrays like this: A=(vol-175a3b54 vol-382c477b vol-8c027acf vol-93d6fed0 vol-71600106 vol-79f7970e vol-e3d6a894 vol-d9d6a8ae vol-8dbbc2fa vol-98c2bbef vol-ae7ed9e3 vol-5540e618 ...
0
votes
1answer
742 views

How to reassign new values to array elements?

I'm trying to figure out like three or four things at the same time.The most I need help with is how to get the greatest number in all the files that I have created on a prior run of my script, that ...
4
votes
4answers
2k views

How can I suppress output from grep, so that it only returns the exit status?

I have the grep command. I'm searching for a keyword from a file, but I don't want to display the match. I just want to know the exit status of the grep.
4
votes
3answers
193 views

Bash: handling “[[ statement ]] || echo problem found ; exit 1” logic

In the statement in the title, there is a problem that even if the statement is true, it will still exit with status 1 because, as I understand it: [[ statement ]] || echo problem found ; exit 1 ...
1
vote
0answers
39 views

List Mails by subject

I'm writing a script to send mails from a mailbox on a remote server and a script to check if the mails are received at another remote server. For this I have configured mutt. What I now need is to ...
1
vote
2answers
70 views

Command working from CLI but not from script

I have a command that I use from the CLI to properly color files, folders, executables, etc. The command that I'm executing looks like this: test -r ~/.dircolors && eval "$(dircolors -b ...
1
vote
4answers
828 views

How do I delete files with spaces in them in bash script?

this is a three part topic to a two part process that still is not working for me: Objective: to manipulate a filename then delete it the filename has spaces between the words then the dot .ext ...