Questions tagged [scripting]

A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

Filter by
Sorted by
Tagged with
0
votes
1answer
43 views

Getting Error with system() in perl

' Number found where operator expected at ./scripttemp.perl line 5, near ""sed -i -r "4" (Missing operator before 4?) String found where operator expected at ./scripttemp.perl line 5, near "}" ...
1
vote
1answer
78 views

$! not being set to the PID of a > >(…) process substitution used with an external command

Bash 4.4.19(1)-release I have below a simple script which is the basis for a logging app. For various reasons I had to use process substitution. The runner is the heart of the app and since ...
1
vote
1answer
41 views

Is it possible for a function to distinguish if it is run like this? “${@}”

This is my simplified script. I am wondering if the proc() can know if it is run directly or through the runner. #!/bin/bash runner () { "${@}" } proc() { eval 'version=$(echo "SUCCESS: ****...
0
votes
1answer
34 views

Extracting two pieces of data from one file and inserting them into two different places of a different file

I have a file named parse.txt that contains the following 2 lines: 60 Moderate I'm hoping to have a command in a bash script that will insert the 60 into line 7, column 17 of a new final.txt file, ...
0
votes
2answers
38 views

I cannot get the PID for this “${@}” 1> >(2log) 2> >(2log2scr | tee >&2)

I searched a bit on how to do this, but I cannot find a solution. I am using process substitution cause of necessity. I want to wait for all the processing to finish before proceeding. How do I get ...
0
votes
3answers
31 views

Are there any “helper” scripts to assist with loading/overriding command arguments?

I have the following script sub.sh: #!/bin/sh . ./sub.conf echo $topic mosquitto_sub -u $user -P $password -h $server -t $topic And the associated settings file sub.conf: topic="#" #-...
1
vote
0answers
75 views

Shell script cannot find file [duplicate]

I am trying to install a gcc-arm version but run into trouble while trying to run the setup shell script. Following step 2 in the prerequisites I downloaded GNU ARM embedded toolchain v4.9-2015q3. ...
0
votes
1answer
72 views

Process Substitution ECHOS undesirable 'shell prompt'. Can I disable it?

NOTE: This question has arisen due to asynchronous processing of 'Process Substitution'. The script responses were deceptive, causing many lost hours. A previously related post is here: cat in process ...
1
vote
2answers
48 views

Script to combine separate csv files

I have two separate files containing information on clients that I would like to merge into one. The first file contains global information, the second is for options. Basically, every client has an ...
0
votes
1answer
33 views

Linux unable to find and execute script, despite being in the correct directory [duplicate]

I have a basic start script for an application that I am trying to run. However, every time I execute it: ./start.sh It fails with this error: -ksh: ./start.sh: not found [No such file or ...
0
votes
1answer
67 views

Can I process command output just before sending it to a file (one liner)?

I have a command processing function that runs its arguments and outputs the results to a file. The outputs of those commands must now be PROCESSED just before going to the file. I have only one ...
0
votes
2answers
30 views

Finding a file by alphabetical order

Using bash, I need to be able to find a file in a specific position when listed alphabetically. For example, if I had the files a, b, c, d, e in a directory, and I wanted to find the third file, I ...
0
votes
0answers
30 views

run script continuously and check for error

I have written below script and it reads the file and when ever there is any 400* or 500* word it will give me error message, and now I want to add two more functionality to my script. I added the ...
0
votes
2answers
72 views

grep files with pattern A but exclude files with pattern B

I want to grep files which include pattern A (iwant) but I want to exclude files which contain pattern B (idontwant). Example: read -p "...what are you looking for: " iwant read -p "...what should ...
0
votes
1answer
23 views

Trying to parse a string in BASH for [ - _ ]

I have a BASH script that allows a user to specify a jobname. Right now we except everything. We feed this jobname into another executable that can only accept the following formats: job_name, ...
-1
votes
1answer
47 views

simple systemd service for execution of shell script

Im trying to start a simple .sh file and it says Failed at step EXEC spawning /etc/start.sh: No such file or directory Content of the gnome.service [Unit] Description=Description for sample script ...
0
votes
1answer
24 views

How to extract Oracle DML (insert,update) queries from a dump file?

Example: $cat data.txt SCN THREAD OPERATION ID OBJECT ID OBJECT NAME REPLICATE OPERATION SQL ------------- ------- ------...
1
vote
2answers
23 views

How can i check if my host command in script got a valid ip

Suppose we only have 1 parameter host $1 How can I check if the above command will give me an answer or: Host $1 not found (NXDOMAIN) and instead of showing an error not found, I would like to ...
1
vote
1answer
27 views

How to count how many times each line appears in a file

I have something like this teithe.gr List item deitel.com parinux.org cs.vt.labs.edu cs.may.ie csse.monash.edu.au amazon.com amazon.com teithe.gr teithe.gr I just want to know how can I count each ...
0
votes
2answers
37 views

I have a text file with with 3 columns separated with : how to sort the second column by the last 2 digits of column 2?

This is an example of the text file: 195.92.211.47:21029:400 195.92.211.48:21023:400 How can I sort the lines of the file by second column's last 2 digits? The second column is always five digits.
0
votes
2answers
39 views

Using grep and logical operators for pattern matching within shell script

Im trying to develop a script that finds a specific pattern in the output of the dig command running against a list of domains. To do this I'm using grep but having difficulty implementing this using ...
2
votes
1answer
66 views

Redirect echo in trap function back to stdout

I'm currently having an issue getting echo statements in my trap function to be printed to stdout. I'm redirecting all output (error and stdout) to a log file from a command that I run. But if it hits ...
0
votes
1answer
64 views

Correcting a shell script

I have got a section of shell script which was working earlier but now it is giving some different results: MSG= while true do themenu getchar = case $answer in 1) ...
0
votes
1answer
32 views

Bash script for grepping string and placing them into array

I'm looking way to make bash script that greps output of command and place strings into array and be able to randomly select 1 string from the array for example every minute and place it as variable, ...
1
vote
2answers
80 views

selective deletion of lines between two patterns

I have a file which contains following content, Hello world Unix!! Its bright world Current time is HH:mm:ss Next action plan is item #3 End of task. Thank you. Hello world Linux!! All actions ...
2
votes
1answer
42 views

Bash script to count number of executions instances does not work

I am writing a script that detects if there is any instance of it already running on my Linux machine and shows on screen the number of instances. The content of the "detect_itself.sh" script is: #!/...
0
votes
1answer
44 views

Execute a remote bash script locally

I've seen that it's possible to run scripts stored locally on a remote server eg.: run a command: ssh USER@HOST 'COMMAND' run a script ssh root@192.168.1.1 'bash -s' < script.sh What about ...
0
votes
2answers
43 views

Strip the output of the ping command?

I would like to as if it is possible to strip the result of the 'ping' command form the last three lines which are always: --- domain.com ping statistics --- 3 packets transmitted, 3 packets received,...
0
votes
2answers
77 views

BASH Tools for conf file manipulation? [closed]

I am wondering if there are any tools for use in bash scripts that can easily allow you to manipulate (add, remove, update) directives inside conf files? e.g. fail2ban.conf has grouped directives, ...
0
votes
2answers
60 views

Progress bar to display progress based on number of files found/completed in for loop?

Is there a progress bar that can show visually completed progress based on the number of detected files found and completed in a for loop like the one below? mkdir -p hflip; for i in *.mp4; do ffmpeg ...
-1
votes
1answer
31 views

Why is this bash script read line code giving me errors? [closed]

Why is this bash script read line code giving me errors? read -p "Does this require cropping? (y/n)? " answer case ${answer:0:1} in y|Y ) mkdir cropped; for i in *.mp4; do ffmpeg -i "$i" -filter:...
0
votes
1answer
65 views

how to add additional command-line usage scenarios to script?

how can one make this script work with both input usage scenarios below? #1 ./script.sh #2 ./script.sh input.file contents of script.sh for i in *.mp4; do ffmpeg -i "$i" "${i%.*}.mp4 ...
-1
votes
3answers
107 views

Is this allowed in an `if statement`?

# optional cropping if [ "$1" == "cropit" ]; then ITS_CROP_TIME= mkdir cropped; for i in *.mp4; do ffmpeg -i "$i" -filter:v "crop=1920:980:0:-100" cropped/"${i%.*}.mp4" rm -r *.mp4 cd ...
0
votes
0answers
41 views

How do you loop over files inside of loop?

I have a script like this: #!bin/bash for FILE in *.score; do plink2 --pfile Predix_chr22.doseN.new.pgen --psam Predix_chr22.doseN.new.psam --pvar Predix_chr22.doseN.new.pvar --pgen Predix_chr22....
1
vote
1answer
24 views

Writing logs for openvpn in Ubuntu18

I've installed openvpn on Ubuntu18, and it works. I'd like to have a log containing only the times when users connect and disconnect. Found a hint how to do it at [https://github.com/furlongm/openvpn-...
-1
votes
1answer
142 views

Shell script for telnet for multiple servers from text file

I am using below code for to telnet the multiple servers. file=ip.txt while read line do ip=$( echo "$line" |cut -d ' ' -f 1 ) port=$( echo "$line" |cut -d ' ' -f 2 ) if telnet $ip $port </...
0
votes
4answers
136 views

Deleting (some) comments from a C program

I need to use a bash script to delete full-line old-style comments from a C program, i.e., comments that begin (/*) and end (*/) on the same line, with no code on the same line.  This is an example of ...
1
vote
0answers
57 views

Setup Automation - Firefox and Addons

I am improving my setup script for new installs and want it to include setting up firefox. One big problem I found is, that it is not possible to install addons via CLI that automatically get updated ...
-1
votes
2answers
89 views

How come my script won't function properly?

I am trying to use my ./script.sh like so: ./compile.sh -n NAME_ALBUM -f 000 000 000 000 -l 000 000 000 000 where -n is ALBUM_NAME and corresponds to the outputted filename being saved where -f ...
3
votes
2answers
95 views

How to include custom command options in a bash script with $1 and $2?

I have a script myscript.sh #!/bin/sh echo $1 $2 which is used something like ... ./myscript.sh foo bar which gives me an output of ... foo bar but how can i make this script include custom ...
-1
votes
3answers
177 views

Variable for SCP command in script

I'm trying to write a script that will check what is the last modified/created file on the server, then copy it to my homedirectory on this server and then copy this file from node to my local machine....
0
votes
0answers
32 views

Repair a corrupted .odp file

I have a corrupted .odp file that cannot open anymore in LibreOffice Impress. There is no back-up available in LibreOffice (.bak file is missing). I was wondering if there are some powerful Linux ...
0
votes
1answer
71 views

Moving files to a bin [closed]

I am having issues with my code below: #!/bin/bash #Removing Files into the Recycle Bin(Deleted Directory) filemove=$1 #Saving the first argument as "filemove" mkdir -p ~/deleted #Create the deleted ...
0
votes
1answer
28 views

Find files and specify some to come first in playlist, and the rest in random order?

The following code creates a list of the files in the directory and then shuffles them in a random order then spits out the file in a text document called list.txt find *.EXT | sed 's:\ :\\\ :g' | ...
2
votes
0answers
78 views

Copying contents of a folder via SCP results in `scp: error: unexpected filename: .`

I was using a script to copy the contents of a folder via SCP, without copying the folder itself. Something like this: scp -i id_rsa -P "$PORT" -r "$HOST:/folder1/folder2/." "backup" (I'm not able ...
0
votes
2answers
45 views

Concatenate the Content of Files from Various Directories with a Blank Line in Between

I have the file dir1.txt that contains the names of the following directories: 2 3 4 Directory 2 contains files 2_1.txt and 2_2.txt Directory 3 contains files 3_1.txt and 3_2.txt Directory 4 ...
2
votes
1answer
142 views

POSIX and Portability | shell scripts | grep -s, grep -q

I am all in for portability in regards to shell scripts. But I am unsure if I am overdoing it right now. In this example, we have a function called confirmation, which accepts the very first ...
0
votes
0answers
9 views

UsbFlashDrive.getLabel meaning

reading through the system logs I can see those two messages USBFlashDrive.isMediaPresent - the media is present in the device USBFlashDrive.getLabel - Getting the label for the USB flash memory ...
0
votes
0answers
12 views

restrict cpu usage of chrome in ubuntu mate

I use ubuntu under virtual machine. whenever if i open too many tabs in chrome or firefox, system hangs. I found there are lot of utility to restrict the cpu usage. has anybody have ready made ...
-1
votes
1answer
24 views

Value addition from a file's row [duplicate]

Suppose I have one file like: apple | red | 2 apple | green | 3 orange | yellow | 3 apple | yellow | 1 Now I need following output as (irrespective of color value should get third number ...