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.

0
votes
1answer
11 views

youtube-dl : how to skip downloads lower than 480p resolution?

When using the popular program youtube-dl, how can I skip download of certain videos, particularly ones that have a lower quality than 480p resolution?
1
vote
2answers
1k views

Passing arguments from one script to another

Let's say I am in a Bash script and am sourcing a file. How do I pass variables to another script after I source the file like this. sed -i 's/ = /=/' $file source $file Let's say file contains ...
1
vote
0answers
20 views

Script - Write stdout and stderr to a file AND to the terminal without pipe [duplicate]

I don't know if it's possible, I would like start a bash script without pipe which write everything to a file and at the same time see the output on the terminal. So I know how to do that with this ...
3
votes
4answers
2k views

Is the output mixed like this because of xargs and how can I fix it?

I'm learning a bit of Bash by using xargs to list whois records for a bunch of IP addresses. The command used is: echo "$1" | tr "\n" "\0" | xargs -0 -n 1 -t -P 3 -I % sh -c 'echo "\n 44rBegin whois ...
4
votes
4answers
52k views

Checking and changing file permission with script

I'm new to bash and I can't get a script working. This is the code that I have: #!/bin/bash file=~/scripts/text.txt if [ -e $file ] then echo "The file exists" elif [ ! -e $file ] then echo "The ...
1
vote
0answers
10 views

systemd service start after network online and time synced

I made a system service for a python script, I want it starts on boot after the server is online and the time is synced correctly. What do I have to add in .service file? I tried in [Unit] with ...
1
vote
1answer
28 views

How to preserve filename and folder structure when using foremost recovery program?

I am desperately needing to run the linux recovery software foremost and preserve filenames and folder structure. As you might know the program renames the recovered files with a numerical value and ...
0
votes
0answers
21 views

check file of sftp and return output to log

I need your assistance. I'm trying to finish a script that I've done but it is not working perfectly. here is the script: #!/bin/bash # iclog=log key="keys/cash_prod_key" date=$(date +%Y%m%d) ...
0
votes
1answer
32 views

Reading commands from a file

I have saved the commands in a file and trying to read it from another file. commands without a pipe are working fine but wherever there is a pipe in command it is not getting executed. can anyone ...
2
votes
4answers
2k views

Is the bin/ directory for storing binary files?

I have seen many tutorials saying that the bin directory is used to store binary files, meaning there is only 0 and 1 in the files in that directory. However, in many cases, I see files in bin that ...
0
votes
0answers
19 views

overwrite DNS domain

We have an enum server that sends all naptr request to an enum provider. The provider only responds back if the domain matches them. We have several domains and I need to intercept the request ...
0
votes
4answers
129 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 ...
0
votes
1answer
15 views

Expanding FEH capabilities to preview RAW files

I would like to preview RAW files in FEH. I now I can do the following nufraw-batch --embedded-image DSC_0151.NEF --output=- | feh - which opens the image in feh, but only works on one image at a ...
0
votes
1answer
1k views

Debian startup script doesn't start

I'm trying to make a specific script load on start on Debian. I have tried to put the script on /etc/rc.local but no success. Now I have made a service script that runs my specific script. The code of ...
1
vote
2answers
53 views

Problem with while function in AWK script

I have a pretty ugly looking script that I use to process evaluation files from simulations, it looks horrible and no I am not a coder, though it usually works, however it is currently not. Just to ...
0
votes
1answer
26 views

csh: Changing path in non-interactive login

I want this: $ ssh nopathcsh@lo 'echo $path' /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games To return this: /usr/bin /bin I have tried changing and ...
6
votes
5answers
17k views

How to check if the current time is between 23:00 and 06:30

I am having trouble grasping how to properly check from a bash script if the current time is between 23:00 and 06:30. I am trying to run an infinite loop to check the time now, and to do something if ...
0
votes
0answers
11 views

i3lock called by the i3-nagbar starts in the background

I am trying to set up a lock script with the i3⁻nagbar command. The current code i have: i3-nagbar -b "lock" "i3lock" -b "shutdown" "shutdown -h 0" And while the shutdown button works, the lock ...
13
votes
4answers
44k views

Execute command in sftp connection through script

This is a very basic question I am just quite new to bash and couldn't figure out how to do this. Googling unfortunately didn't get me anywhere. My goal is to connect with sftp to a server, upload a ...
0
votes
0answers
50 views

Strange counting problem of variable in bash script [duplicate]

I have the following bash script which works fine until I get to number 9 (/dev/sdj) where it does not produce the expected output. hdd1="$(sudo fdisk -l | grep "Disk /dev/sd" | awk '{print$2}' | sed ...
1
vote
2answers
36 views

Bash script is breaking after Continue statement

Here I'm trying to ssh to multiple servers remotely and check whether any processes running on those servers and wait until the process to get finished. while read ip name do process=alive while [...
0
votes
0answers
15 views

arch linux udev script trigger

I am looking for some support with an issue I have come across today. What I am trying to do: I am trying to use udev rules to trigger a python script which does multiple things including making a ...
0
votes
0answers
5 views

Launch Openbox actions through script or cli

I was wondering if it is possible to run openbox actions, like the ones that can be found on rc.xml like MoveResizeTo , through a console command so I can launch it from terminal or inside a bash ...
0
votes
2answers
50 views

Single text file: Compare the first n characters of each line and the next. If they are equal print the longer of the two in output file

I am using the Ubuntu bash. My file contains paths from a filesystem. E.g. C:\users\username\subfolder\thisismyfile.txt C:\users\username\subfolder\thisismyfileplusadate.txt C:\users\username\...
1
vote
0answers
24 views

Run bash script as application, such as a Desktop icon does [duplicate]

What I can I do to execute bash script as application like open the "Desktop icon". Any idea for where can I start?
0
votes
2answers
28 views

Returning wrong results in perl script [duplicate]

I am running this command on linux shell it works smoothly sed -i 's/\[-.*-]//g' error .txt What it does is it removes patterns like [-any text-] along with the brackets and - sign. but when I try ...
68
votes
2answers
226k 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
0answers
72 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. ...
3
votes
1answer
890 views

Upload to youtube using shell script

I've searched the youtube API but still not clear whether this is possible. I have a shell script that uses FFMPEG to convert a video. After being converted I want to have the video automatically ...
-4
votes
0answers
34 views

Script to add fuction header to all api's in cpp file [closed]

How to add function header template like this - **************************************************************** Function Name : XXXXXXXXXXXXXXX(setNameOfStdent to be auto filled) Description : ...
0
votes
3answers
83 views

perl regex - How to match foobar that does not begin with (\s*//\s*)

Basically I want to find foobar on uncommented lines like: // foobar # do not match me foobar # match me otherfoobar # do not match me To match the commented lines I use this: ^(\s*//...
0
votes
2answers
36 views

Group Together Items By Consecutive Number

I have a series of files that look like the below, I need to group them into "consecutive groups", each line starts with a number, the file should be read from top to bottom, and if the next line ...
0
votes
0answers
28 views

Debian 9 stretch - How to prompt user from rc.local script and echo in current terminal

I need to create an easy to go Debian VM for new developers on my team. I run a script on boot with rc.local. This is a small test script : #!/bin/bash exec < /dev/tty1 # Checking if user ...
1
vote
0answers
33 views

What is difference between `` and $() for command-substitution in bash scripting? [duplicate]

I'm new to Linux and StackExchange. My English is pretty bad, and I'm sorry for mistakes. What is the differences between `` and $()? Does it matter what to use and when? I'll be grateful for ...
1
vote
1answer
35 views

getopts in function that is called more than once in a script, getopts doesn't detect any opts after 1st function call [duplicate]

I have read the getopts man page and am still not sure about this use case. getopts is not detecting any available options the second time a function is called in the same script. As you can see ...
1
vote
1answer
66 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 ...
0
votes
1answer
58 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
votes
1answer
30 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
37 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 "}" ...
-2
votes
0answers
32 views

Using Grep in perl script [closed]

I want to execute the grep command inside my perl script. this is my command : grep -nr "{+" error.txt > error1.txt I want to find this character in file error.txt and want to print the line ...
1
vote
1answer
40 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
31 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
35 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
24 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="#" #-...
0
votes
4answers
424 views

print entire line after an awk and grep

I need to search multiple patterns on the third column of a file, and then print the whole line. I am using this one below but how do I get it to print the whole line where there is a match? awk '{...
0
votes
1answer
63 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 ...
1
vote
2answers
31 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
32 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
2answers
28 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
24 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 ...