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)

0
votes
1answer
16 views

Using user defined function in bash scripts

I wrote the following script in the test.sh: #!/bin/sh compare() { if [ $1 != root ]; then echo "Fail" >> CAT1.txt fi } awk -F: '$4 == 0' /etc/passwd | cut -d: f1 | xargs -n1 -i bash -c ...
1
vote
2answers
654 views

Nmap script execution to detect heartbleed is failing

Wanting to setup Nmap on my Ubuntu 14.04 LTS system to detect HeartBleed vulnerability. I followed the instructions here: ...
-3
votes
0answers
10 views

Run DB scripts in linux

I want to run DB Scripts in linux but I am not able to do so . Can anyone give me the idea how to run DB Scripts?
1
vote
2answers
62 views

Bash script to read file and echo different lines to output files

I have a log.txt file with various lines of strings and information. I want to write a script to read the log.txt file line by line and any line that contains the word debug I want to put that line ...
0
votes
2answers
300 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 ...
0
votes
1answer
26 views

/bin/sh script error “arithmetic expression: expecting primary: ” + “ ”

ERROR: ./client-disconnect.sh: 22: ./client-disconnect.sh: arithmetic expression: expecting primary: " + " I just need to know how to fix it. It's for user accounting with OpenVPN. Script ...
1
vote
1answer
20 views

What's the Fedora equivalent of /var/lib/dpkg/info/[…].prerm?

Example file: /var/lib/dpkg/info/util-linux.prerm What's the Fedora equivalent of this file? (Not limited to util-linux - generic question for any package.) Use case: A prerm script is failing. ...
-3
votes
1answer
24 views

Need help running a command based on a file in the directory

I have some scripts setup that I would like a master script to call based on a files appearance in a directory. Basically I have what's show below. Script A uses file a Script B uses file b ...
2
votes
3answers
40 views

Split command and arguments, and put into variable in a bash script

I have a script that repeats the same (very long) grep command many times. I want to make the script more readable by cutting the line length, so I tried to put parts of the command into variables. ...
0
votes
0answers
17 views

Script for changing monitor refresh rate when fullscreen on a specific website.

Premise I recently discovered this website where I can watch legal streaming of plenty of animes. They use a flash player and the CEO said that, for legal reasons, they can't use a HTML5 player. The ...
1
vote
0answers
21 views

-devilspie doesn't play nice with spawning new terminals

I'm trying to configure devilspie so that on detection of opening a certain directory it runs a script to mount that directory over a network. I don't think the script itself is too important but ...
0
votes
2answers
46 views

viewing printf after pipe (or subshell?)

Ok, this is hard to distill to a single question because it really depends on how I'm going to troubleshoot it. The following script is meant to pipe mount.cifs commands to a while loop that enters ...
1
vote
0answers
17 views

Creating and mounting partition automtically

I am running raspberry pi on raspbian wheezy, and I'd like to create script that automatically creates new partition on unused area of disk and mountpoints on it so it'll always mount on same ...
1
vote
2answers
6k views

Run a script at startup

I am using Ubuntu 14.04. I wrote a small script named trial. The contents of the script are as follows: #!/bin/sh SHELL=/bin/sh PATH=/bin:/sbin:/usr/bin:/usr/sbin sh -c firefox I copied the ...
4
votes
3answers
279 views

Exiting a shell script with nested loops

I have a shell script with nested loops and just found out that "exit" doesn't really exit the script, but only the current loop. Is there another way to completely exit the script on a certain error ...
0
votes
3answers
645 views

Split XML file into multiple files

I have an xml file that have different nodes, I want to split files like this: <unix> <mm> </unix> <osx> <nn> </osx> When I run the script I want it to make ...
0
votes
1answer
18 views

Old file deletion script

I used this script: #!/bin/sh for file in "$( find /var/backup/web2 -type f -mtime +1 -maxdepth 1 -exec rm -f {} \; )" do rm -f $file done exit 0 to delete files older than 24h from fixed ...
1
vote
0answers
7 views

Application started in /etc/X11/xdm/Xsetup can't receive key presses

I'm using xdm (and I'd like to keep it that way) for a project and I need a terminal to run a script before the login prompt. The script requires some user input, however, it doesn't seem to work. ...
0
votes
2answers
41 views

Why Are There Three Processing Running For One Script?

I have the following line in crontab. @reboot /usr/bin/teamspeak3-server_linux-amd64/ts3server_minimal_runscript.sh When I reboot, the script runs (i.e. my Teamspeak 3 server starts) in the ...
0
votes
1answer
40 views

A bash script that can automate git commit message contents

Normally when I commit a change to a submodule in Git (and if that's the only change), I will provide the result of git diff <submodule-name> to the body of the commit message (with ...
1
vote
1answer
28 views

Application Shortcut To Launch On System Boot

I have a ts3.desktop file in my /usr/share/applications folder that I want to run on system boot. Can you please advise me on how this can be done?
0
votes
1answer
18 views

Substituting the value with spaces for a variable in bash script - the correct way

I have a compilation script that can compile the program with and without the debug symbols. I want to ask via bash prompt ( read ) the user to choose whether he wants a debug version or not with ...
4
votes
1answer
7k 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 ...
3
votes
3answers
66 views

Converting rows to row groups

Can somebody please help me with the below conversion shell script ? Source File File 1 : for example EXCHANGE_ID : 192, 410, EXCHANGE_DTTM : ...
1
vote
2answers
53 views

How do i search for certain sections of a file and then extract only relevant information within that section?

So I have a text file that is a server report and has about 1000 lines of information in it. I'm trying to write a script that can search the report for only certain pieces of information I'm looking ...
1
vote
2answers
29 views

Why does trying to run a python executable return ': No such file or directory' after transferring it to server via FTP? [duplicate]

I'm having an issue where when I transfer a Python file to my VPS via FTP and try to run it using ./foo.py I am returned with the error: : No such file or directory. The error seams to indicate that ...
0
votes
2answers
63 views

Bash script that detects if a file is the correct size

I'm trying to make this bash script dispatch and email when it detects that a certain type of file (files ending in ".gz"), which was last modified 24 hours ago, is below a certain size in a ...
-3
votes
0answers
40 views

Help with script to add new users and assign groups

!#/bin/bash User script Adds user echo -n "Username: " read user_name Creates password sudo passwd $user_name Creates group echo -n "Group: " read group_name sudo usermod -G $group_name ...
0
votes
0answers
19 views

Can rpm call an external script stored somewhere in the package during installation?

I have a package which is being retooled for in house purposes. Mostly making changes to the configuration files. The files need to be somewhat dynamic so changing the config files at source isn't ...
2
votes
2answers
672 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
4answers
126 views

How to use and/or conditional in shell script

I have an if statement in a script. It looks like this: if [ "$a" != "0" -a "$b" != "100" ]; then #some commands here If I'm not mistaken, the line above will work if both conditions are true. ...
1
vote
1answer
55 views

Bash script to edit text in csv-format

As part of an inventory bash script I am checking SFP modules and adding them to a .csv-file. The format currently looks like this, with varying lengths: RO01;1000BaseSX SFP;1000BaseSX SFP ...
3
votes
1answer
48 views

check for “errors” or “ORA-”

I want to check for "errors" or "ORA-" in Y.if there is an error then exit Y=`sqlplus -s user/passwd<< EOF exec test_Proc; exit; EOF` if [ echo $Y | awk '/ERROR/ || /ORA-/' ] ; then exit 1 fi ...
3
votes
3answers
130 views

remove all instances of _000 from multiple files

Had to recover my music library from a HDD which died.... got everything I wanted but all music track names have _000 added at the end. I really don't fancy going through 8000 individual music tracks ...
1
vote
2answers
62 views

How do I test if my variable is not in a set?

I am trying to modify the bash shell script and need some assistance. I have a directory with a bunch of files. What I need is to go through the files in a loop and if the file name not in a specific ...
1
vote
1answer
45 views

Is there a tool that automatically inserts and updates a script header block for e.g. shell or Python scripts?

I found scripts by a former admin who scripted quite nice things with Bash or Python. All his scripts are well formatted and equipped with a always similar looking "script header" or "code header", I ...
2
votes
3answers
2k views

Scan for Network attached devices

Is there a way to scan for computers on the network through the command line and get their IP, MAC and DNS names without knowing anything about them?
1
vote
1answer
68 views

delete multiple remote files with the FTP command

Right now we have a script that uses the FTP mget command to download all the files in a specific location. After after verifying the files have successfully downloaded we run a ftp delete command ...
1
vote
2answers
33 views

Prevent certain lines of a script to run as root

Suppose I am writing a shell script that requires root privileges to run, for example- #!/bin/sh ip -s -s neigh flush all ufw enable How can I prevent certain lines of code to be run as root, i.e. ...
1
vote
1answer
34 views

Bash script to detect a file modified yesterday and check if its size is above a certain threshold

I'm writing a script to stat all files in a directory, and then find specific files that were created yesterday and tell me if they are larger than a certain size or not. So basically I need this to ...
1
vote
1answer
33 views

UNIX Script not reading the folders with spaces [closed]

I have a UNIX script which is supposed to scan all the folders and return the files older than speciific amount of time. I gave the logic as below, but the script is not able to read the folders with ...
0
votes
2answers
25 views

Unable to perform a simple multiplication in script

I am havingf trouble performing a simple multiplication in my script. while read A B C do tmp=$A\*$C/100 echo $tmp >> out1.txt done < foo.txt foo.txt: 13721725 99 100 ...
2
votes
2answers
5k 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
2answers
335 views

How to set Ruby GEM_HOME and GEM_PATH

I'm a NOVICE user of Linux and using Linux mint 17.1 I've reinstalled Linux mint 20 time in last 3 days for that issue but could not fix it I'm trying to install ruby on rails using rvm what ...
0
votes
4answers
43 views

tabs in variable not working

I have this lines that i will insert in a mail called "header". header=" ------------------------------------- Name\tAge\tGender\tAddress ------------------------------------- " Unfortunately, the ...
28
votes
3answers
15k views

What does it mean to have a $“dollarsign-prefixed string” in a script?

I just saw this in an init script: echo $"Stopping Apache" What is that dollar-sign for? My research so far: I found this in the bash manual: extquote If set, $'string' and ...
10
votes
2answers
123 views

Correct behavior of EXIT and ERR traps when using `set -eu`

I'm observing some weird behavior when using set -e (errexit), set -u (nounset) along with ERR and EXIT traps. They seem related, so putting them into one question seems reasonably. 1) set -u does ...
2
votes
5answers
262 views

Bash script: check if a file is a text file [closed]

I am writing a menu based bash script, one of the menu options is to send an email with a text file attachment. I am having trouble with checking if my file is a text file. Here is what I have: ...
2
votes
2answers
540 views

Script that unpacks a initrd, allows editing of the preseed.cfg and the packs it to cpio and gzip again

I want to program a script that allows what is said in the title. So basically I gunzip the initrd, than unpack the cpio, open vi to allow editing, save, pack with cpio, and gzip again, so nothing ...
1
vote
1answer
51 views

Need help using Netcat

I have a file on my server that has HL7 messages spread out by a space. Example below. I am wanting to send one of these messages at a time in a continual loop until stopping the script with ctrl+c. I ...