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)

9
votes
1answer
1k views

Can capabilities be used in scripts without setcap'ing the interpreter binary?

Right now I'm using cap_net_bind_service MY_USERNAME in /etc/security/capability.conf. Now I just need to set cap_net_bind_service+i on the interpreter of my favouite scripting language to be able to ...
1
vote
1answer
26 views

Find and list duplicate directories

I have directory that has a number of sub-directories and would like to find any duplicates. The folder structure looks something like this: └── Top_Dir └── Level_1_Dir ├── standard_cat ...
0
votes
0answers
15 views

Extract CSV gz file and convert to JSON

Is it possible to extract a CSV gz file stored on an external URL's public_html folder and then convert that data into JSON and then save it as .json in one command?
2
votes
2answers
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 ...
32
votes
12answers
12k views

Object-oriented shell for *nix

Preface: I love bash and have no intention of starting any sort of argument or holy-war, and hopefully this is not an extremely naive question. This question is somewhat related to this post on ...
1
vote
1answer
53 views

uniquely remove unwanted lines in multiple files

I need to remove unnecessary data from multiple output files part of each file looks like this # BLASTN 2.3.0+ # Query: M03117:99:000000000-ALL7G:1:1101:18697:4431_2:N:0:196 # Database: /home/alex/...
107
votes
7answers
69k views

Allow setuid on shell scripts

The setuid permission bit tells Linux to run a program with the effective user id of the owner instead of the executor: > cat setuid-test.c #include <stdio.h> #include <unistd.h> int ...
-2
votes
2answers
37 views

Data Manupulation required your help

I have a data as mentioned below. host_name Server1.domain.com contacts DL - Desktop contact_groups ravi, raj, rahim host_name Server2.domain.com contact_groups DL-Server host_name Server3....
1
vote
1answer
37 views

Using Grep In For Loop

File1 contains: 421 RP-001 421 RP-002 421 RP-003 550 SC-001 550 SC-002 550 SC-003 550 SC-004 550 DY-001 550 DY-002 550 DY-001 550 OU-001 550 OU-002 Script: #!/bin/bash Elogs=/home/elogs.txt ...
0
votes
1answer
38 views

retrieve numbers with 0 for a single int value

In my script, I need to get a 0 for numbers <=9. When the user types any number, I add 5 to it and if the result is less than 9, I need to print a 0 in order to have a 2-digit number (like 07,08,09 ...
1
vote
2answers
1k views

script to add users to otrs

I'm looking for a fast way to import customer users into otrs (ticket system) I have an export from Active Directory with: firstname lastname password email username There is a script in the otrs/...
1
vote
1answer
45 views

Is there a way to create a screen windows from shell script?

I am trying to write a script that creates a new screen session and creates 4 windows within it. I am able to create the screen session, finding it difficult to find out how to replicate Ctrl+A+C, in ...
1
vote
2answers
46 views

Compare string in two files And Merge its Output

I am trying to get the bandwidth of the domain from one file and its hits details from another file. The format of the two files is as follows: bandwidth.txt aadrivingschool.ws 2840.36M ...
2
votes
1answer
24 views

Adding multiple comments to debchange in “batch mode”?

I'm trying to automate a deb package builder for a git repository, as part of which I want to get a bunch of commit comments (since the last package release) and put them into multiple comments in ...
4
votes
4answers
44 views

Running multiple programs in the background and checking their return value

suppose I want to run a few (say, three) programs at once, like this program1 & program2 & program3 & if I want to know their pid's, I think the best way is to store them, like this ...
5
votes
2answers
2k views

Scripting htdigest -c /path/to/file/$user $user $password in Bash

I want to be able to script with a password in variable $password. htdigest -c /etc/apache2/pw/$user $user $password At the moment it asks me to manually enter a password; this is not going to be ...
1
vote
1answer
80 views

Summarize certain data fields of apache CLF log file

I want to grep some information from raw combined log format apache logs: 51.254.56.62 - - [01/Jun/2016:20:49:28 +0500] "GET /vendors/jquery.slimscroll.min.js HTTP/1.1" 404 - "http://networkconfig....
7
votes
2answers
2k views

How does this find command using “find … -exec sh -c '…' sh {} +” work?

@StephaneChazelas posted the following solution to this Q&A: Having some trouble using “find -exec {} +”. $ find . -iname "*.extension" -exec sh -c ' exec <command> "$@" <additional ...
1
vote
3answers
43 views

Help in separating columns from command into a new command

I'm a noob scripter, and I'm trying to create a script for automatic device creation. I'm pretty far already, but I am stuck at one point. The source file looks like this: dev1 size 1024 dev2 size ...
0
votes
0answers
30 views

Significance of shell script with XML

I have recently joined anew project and experienced the structure where Shell scripts are usually directed to a target which is set in XML and that XML containing action in the tags which needs to be ...
0
votes
1answer
49 views

Bash script to install package if already not installed (From a directory with many packages) - Fedora 17

I have a directory full of rpms (And their dependencies). Currently I am executing yum localinstall ./packages_directory/*.rpm to install all packages in there. It automatically skips the ones already ...
1
vote
0answers
30 views

Maintaining a window open until completion of another task [closed]

Aim: keep a GUI window open only for the duration of another command/script being run Current Method for this: When current time matches command/script completion time, close the GUI window I'm ...
-2
votes
0answers
19 views

Merge records in a pipe delimited files when first column value is same, based on the date field in the file

Sample File Input: CustomerKey|EmailAddress|storeID|preferenceCd1|preferenceCd2|preferenceCd3|preferenceCd4|preferenceCd5|modifiedSystem|modifiedDate 1006374|meeb12@test.com||2R05||||||2015-03-18 06:...
0
votes
1answer
41 views

How to use TWO “for statements” in a shell script?

Writing script to create user accounts. Script is written to echo the useradd command (so I can make sure it will work as expected). I have a file newemploy.txt with Employee Names (first and last, ...
-1
votes
0answers
22 views

Loading configuration via putty

I have a NVR hybrid system that runs off of linux. Is there a way I could load a configuration file into this NVR via putty? Basically the file would be a snapshot of a finished NVR with the ntp set ...
14
votes
2answers
15k views

How to automatically record all your terminal sessions with script utility

What I want to achieve is be able to record my terminal sessions to file automatically whenever I use Yakuake/Konsole. It's easy to achieve if at the start of my session I do: script -f /home/$USER/...
0
votes
0answers
13 views

Automatically set Light and Dark Themes to interchange at Given times

I have a specific setting for my light theme and darker theme to use at night.How can I automate the interchange process.?
43
votes
6answers
59k 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 ...
1
vote
1answer
33 views

substitute at beginning of line

I want to search a pattern and insert a character at the beginning of a line using regsub in TcL. I have to use TcL only Input file mna1 x a1 vss vbn nch_svt_mac nfin=nfin_n1 l=ln1 mna2 x a2 vss vbn ...
0
votes
1answer
13 views

linux command has different behaviour in script

(Question SOLVED and edited for helping someone else that need it or have the same mistake, now with the code in the post for better readability) I am trying to create a script that does something if ...
4
votes
2answers
66 views

Rename Multiple files gzips them and delete older than 10 days

I'm new to Linux/Unix and slowly learning it step by step. Unfortunately on today’s job interview was surprised by a task to do (which of course I didn’t know). I was asked to prepare a bash script ...
2
votes
4answers
56 views

How do i find over 200K differently named files and output

We have a SAN with a lot (over 5 million) of files. Because of some freak mistake from a developer script, some files have been deleted and we now have to figure out which files got deleted. Now, I ...
-1
votes
0answers
28 views

Automating yum install using python

yum install (package-name) How can I write a python script to execute the command above and see if its successful or not? This should be the algorithm: run command yum install <package-name> ...
1
vote
1answer
36 views

Point and click Ubuntu 16.04 bash script randomly alternates output behavior

I wrote and tested the following point and click Ubuntu 16.04 bash script for the purpose of completely killing a mono-service RecorderManager.exe process by literally killing the process id returned ...
1
vote
1answer
33 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. ...
3
votes
1answer
61 views

How variables inside braces are evaluated

I'm new to shell scripting and I came across these expressions ${var:-val} and ${var-val} ${var:+val} and ${var+val} ${var:=val} and ${var=val} so how are they evaluated and what are the ...
1
vote
1answer
102 views

How to Wget with Subset Condition?

I want to download a subset of data recursively in the website that is within HTML class .container current main page in .container daughter pages of links also in .containers in daughter pages ...
1
vote
0answers
17 views

Change existing dovecot maildir installation from m-UTF7 charset to UTF8 to avoid breaking TAB

In an existing dovecot installation with many pre-existing folders using regional characters I would like to change m-UTF7 (.&AMk-l&AOk-ments envoy&AOk-s) foldernames to UTF8 (.Éléments ...
1
vote
2answers
51 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 ...
2
votes
1answer
33 views

How can I use sed to snip a line off of a string?

I'm writing a script to display the domain registrar info and I'm trying to snip off a few lines from what I already have I currently have it grabbing all the indented text from a whois. Now I'm ...
-1
votes
1answer
71 views

tftp non-intearctive mode not working

tftp inline not working root@kali:~/scripts/recon_enum/exploit-db# tftp -v 192.xxx.xx.xxx 69 -c get text.txt text.txt usage: tftp host-name [port] tftp> but its working in interactive mode: ...
3
votes
1answer
63 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", "...
3
votes
1answer
33 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 ...
3
votes
1answer
56 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
31 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
29 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 ...
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
43 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
42 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
59 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 \033[5;31;47mMoreText\033[...