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
1answer
17 views

How to automate mutt in removing old mailing-list emails?

In mutt I perform following sequence of steps: $ mutt -f imaps://imap.example.com username password [shift]+[D] ~C mailinglist1@domain.com [shift]+[D] ~C mailinglist2@domain.com (...) [shift]+[D] ~C ...
2
votes
1answer
47 views

Join arbitrary lines to output as one line

I want to join the 3rd and 5th line of a file to the output of a script without trailing new lines. Is it possible to implement this construction by using the code: { echo 'Some text' echo 'Some ...
1
vote
2answers
24 views

Nautilus-script to move file into same name directory

How can I create a Nautilus script that moves a the selected file into a new folder with the same name? My starting point: /home/user/123 here 123 is a file with no extension My goal here is to ...
1
vote
1answer
21 views

'xz -d' vs. `unxz`

Why is xz -d preferred over unxz when writing scripts? From the man page for xz 5.1.0alpha: When writing scripts that need to decompress files, it is recommended to always use the name xz with ...
1
vote
1answer
29 views

Use variables in here-string

To feed input to an interactive script, I've been using a here-string: script <<< $'1 2\n3 4\n5 6\nq' This effectively enters 1 2 3 4 5 6 q into the script. But how can I replace one of ...
0
votes
0answers
15 views

notify-send not showing when executing with sudo [duplicate]

In short: I have a scripting finding, fixing and mounting a partition, thus this needs sudo / su permissions. System: Gnome 16.04 - amd64 notify-send "a message" shows a notification as expected, ...
0
votes
2answers
28 views

simple for loop script to build out ipv6 subnet

I am trying to use nmap to scan a /119 IPv6 network. (512 addresses). Before I do this I want to generate a file that will populate all of the ip addresses in that range. The network info is as ...
3
votes
2answers
38 views

Looking for a convenient way to create a “constant array”

In zsh, is there a convenient way to create an array of n copies of the same integer? Context: In a shell script, I need to create an array, tile_lengths, consisting of two longish constant blocks. ...
0
votes
2answers
54 views

Create blinking text with echo and escape characters [duplicate]

I have learned about formatting options used in shell scripting, which go like this: \033[37:40mAnyText\033[0m Now I want to echo some text like this: echo -e "SomeText ...
1
vote
0answers
15 views

detecting sound from speakers

I have decided to make a radio from my old laptop. I installed Puppy linux and set special features, like: after waking up, it turns on my favorite online radio (openFM) and switches off the screen. ...
-1
votes
0answers
34 views

How to write the shell script which check if the file is present on the cluster file system?

Suppose we have pscp on Windows, and remote control to Linux cluster through key key.ppk, the user and host is name@cluster.com. How, by using shell script (in cmd file), check if some file is present ...
1
vote
1answer
26 views

SSH, Putty and sending data on the cluster

I have ssh access to the cluster through Putty. I also have the script, which, after its launch, makes some commands, generates data and sends it via email. Is it possible to provide following: I ...
0
votes
3answers
2k 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 ...
8
votes
4answers
6k views

Hybrid code in shell scripts. Sharing variables

This answer discusses how to run a multi-line Python snippet from the command line in a terminal. I noticed that the answer works great within shell scripts, even with nested indentation, which is ...
1
vote
2answers
412 views

How to execute “Yes/No” operation as long as I press “Yes” in bash?

Suppose I have the Yes/No construction in bash script: read -r -p "Yes or no?" response if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]] then do ... else exit 0 fi I want this construction to be ...
0
votes
0answers
15 views

Scripts On Demand [on hold]

Ok this is more like a query. I want to ask if someone knows a platform where I can get bash scripts for system administration. Thanks
0
votes
1answer
98 views

Find string in text file and execute a script depending of the result

I have a file (Data.txt) with something like this: A=1234597890 B=192.168.1.1 sometimes B goes first and sometimes only A or B. So, If I find: A, Print A content and execute A script B, ...
1
vote
1answer
36 views

Debian (jessie) with XFCE, Sessions and Startup: Application Autostart

Long-time lurker, first time question-asker. I am running Debian jessie with XFCE, kernel 3.16.7. In the course of setting up Conky to run at startup, I wrote a bash script to... well.. run Conky. ...
0
votes
1answer
39 views

Few questions about realization of commands using bash scripts

I'm the newbie into scripting, so, please, sorry for annoying questions. I need to create bash script file, which after its launch does following. 1) Suppose after launching the script I enter the ...
1
vote
3answers
68 views

Is there any way of speeding up this DNS script I made? [on hold]

Part of my work is doing a lot of different DNS lookups, so I created a script that displays the information that I need in a neat fashion. Problem is it's not very fast. Doing a bash -x I can see ...
6
votes
4answers
4k views

Split PDF into documents with several pages each

There are several resources on the web explaining how one can split a PDF into many files with on page per file. But how can you split them into chunks of, say, five pages each? I have looked into ...
0
votes
1answer
2k 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 ...
1
vote
0answers
15 views

Systemd and controlling network settings

I'm trying to figure out best way to control network settings in best way possible in real time. My current plan is this: Start ip -s -d -o monitor with systemd and write its output to file ...
2
votes
1answer
2k views

autologin console as root on fedora

Can someone help to autologin in console text mode as root in fedora, usually I can do using script like this : /sbin/autologin.sh: #!/bin/bash 0</dev/$1 1>/dev/$1 2>&1 cat /etc/issue ...
0
votes
0answers
38 views

script to delete files when it cross limit size

I want to make a script which delete files when it cross 70% usage. In directory there are logs files has 9.6 MB size. I want that if directory cross 70% then it find oldest files and delete them. ...
1
vote
2answers
42 views

How can I add a filter to my grep script to NOT include a string?

I'm working on a script that will separate the Registrar information from a domains whois. So far it's working enough but there are a few things that I want to remove in order for it to be a bit ...
0
votes
3answers
55 views

Efficiently compare If variable exists and is not equal

I have a problem with the sh script syntax. I wrote a script for my Asus router. The script works perfectly. But I have this line: if [[ "$OldIP" && "$StartIP" != "$OldIP" ]]; then echo OK; ...
19
votes
2answers
54k views

su options - running command as another user

I was wondering how to run a command as another user from a script. I have the script's owner set as root. I also have the following command being run within the script to run the command as the ...
1
vote
2answers
40 views

How to execute a command when internet is back

Sometimes my wifi is connected to router but my router is not connected to internet. How can I execute a command when my internet is back (from command line)? I want to execute: mpg123 ...
1
vote
3answers
95 views

How can I compare different files without opening them?

I have two directories A and B; each one contains a lot of sub-directories geom001, geom002 ....etc each sub-directory contains a file named results. I want to compare, without opening any of ...
3
votes
1answer
53 views

Rename files based on JSON content

I have two sets of files; file1.txt file1.json file2.txt file2.json file3.txt file3.json ... fileN.txt fileN.json json files contain the following format: {"ago": "59 sec ago", ...
0
votes
2answers
48 views

cut -c won't work on my .sh file [closed]

I have tried the following commands cut -c-11 ifshell.sh cat ifshell.sh | cut -c-11 ifshell.sh cat ifshell.sh | awk '{print $1} | cut -c-11 ifshell.sh But every time I get the full contents of ...
0
votes
1answer
3k 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
1
vote
1answer
74 views

Script fails, but copy and paste from script works

I made a script to check the computer's processor count and then change all references of the processor number in another script in accordance with that.  I tested it first by copying and pasting it ...
1
vote
1answer
32 views

find matching URLs in a line, then shorten them to the domain name

I am new to the Linux command line and need some help. I have a log file I am writing a script for so it only shows certain fields of output. The last bit I need is to shorten the URL's so that it ...
1
vote
2answers
554 views

How do you keep the password hidden when invoked during the su command?

This is the first time it has happened to me where I am using the su command and it actually displays the password on the terminal and doesn't stay hidden. Here is my code snippet: sshpass -p ...
3
votes
2answers
25 views

Improving execution speed of Screen Brightness Script

xrandr --output LVDS-1 --brightness $(bc -l <<<"$(sed 's/Brightness: //' <<<$(xrandr --prop --verbose | grep Brightness)) $(if [ "$1" = "+" ];then echo +;else echo -;fi) 0.1") I ...
0
votes
3answers
45 views

How can I subtract two variables in bash?

Hi Guys am getting error please help to sort out. I am new to scripting Script: #!/bin/bash value='55' size=`df -kh | grep '/vol/cdr/MCA' | awk '{print $5}'| sed 's/%//g'` if [ "$size" -gt "$value" ...
0
votes
0answers
23 views

What is the difference between '[' and '[['? [duplicate]

(Hope this is no duplicate) So I have a part of script like this: $ a='f' $ [ $a = [fF] ] && echo yes || echo no no $ [[ $a = [fF] ]] && echo yes || echo no yes So, why do the ...
1
vote
1answer
40 views

How to follow the activity of one specific file [closed]

I have currently MAAS deployed on one of the servers. It all works (most of the time). Now I have added some lines in the WOL file for MAAS (/etc/maas/templates/power/ether_wake.template). I wanted to ...
3
votes
2answers
36 views

Collate image list with name

How to create a collation of images in the format: image_name_1 [IMAGE#1] image_name_2 [IMAGE#2] image_name_3 [IMAGE#3] ... Using Imagemagick I can say something like: montage -label '%f' -mode ...
1
vote
1answer
31 views

How can I edit my bash script to account for whitespace entries? [duplicate]

I made a script to automate ffmpeg conversion from mkv > m4v > open the m4v in Subler.app to import the metadata manually, at which point I'll move the file into my iTunes library. I use iTunes ...
1
vote
1answer
1k views

How do you make case statements with ranges

I'm supposed to: Make a case statement that will display the a grade after input. With no loop or conditional. A=90-100, B=80-89, C=70-79, D=60-69, F=0-59 This is what I have so far: ...
5
votes
2answers
20k views

Execute shell script from php, as root user?

Need to execute the following line from PHP: $res = shell_exec('sudo sh /home/nicklas/cronjobs/make_account.sh username password'); The problem is nothing happens on execution. If i try to ...
0
votes
2answers
33 views

pausing a loop in AIX to wait for user input

I'm searching for a scripting mechanism that can realize the following idea. Loop over a list and stop/wait on "read x" until the next input from a user. I know the following script is not working! As ...
0
votes
4answers
957 views

Permission denied when run script via ssh

I wrote script which download via scp and install some packages. SSH keys are added to host and when I run [root@HostB ~]# ./myscript everything is ok and packages are downloaded via scp without ...
2
votes
1answer
23 views

Silhouette from an image

How can I create silhouette from an image in linux using the terminal? By creating silhouette I mean - how do I turn the RGB components values of an RGBA image to #000000, while preserving the alpha ...
-5
votes
1answer
56 views

Shell script to delete logs when the disk space reaches 90%

I need help to develop a shell script to delete the logs automatically once the disk space reaches 90%. I can add this shell script to crontab jobs.
1
vote
3answers
35 views

How to add the aggregated numbers in a file

I need to write a script which will add the values for the same string in different lines. For example when a file contains the following: abc,10 xyz,20, abc,30, ghd,40 xyz,10 script should check ...
3
votes
0answers
47 views

Check if a remote machine is in a cluster

How can I verify if a remote machine is a cluster machine? I just created the following ssh command to verify if the remote machine is a VRTS cluster or a Linux availability Red Hat cluster ...