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

Zsh script to recursively unrar into a folder with the same name

Is it possible to use a zsh script to unrar all directories within another directory? As follows: dir |_dir1.rar |_dir2.rar |_dir3.rar I would like the command not to include the cd. I will cd into ...
0 votes
0 answers
18 views

Autoselection for gmx trjcat using bash shell

I would like to auto select c for continue for gmx trjcat. The following command was used: echo 'c c c c c' | gmx trjcat -f trajectory1.xtc trajectory2.xtc trajectory3.xtc trajectory4.xtc trajectory5....
0 votes
1 answer
37 views

ssh EOF in bash script - how to store value of command?

I need to basically copy only the last created folder in a directory of many folders within an SSH session. I have the correct find command to do this, but I just can't seem to store the result within ...
-1 votes
0 answers
28 views

how to process reading a file and extracting values

I have file (yaml): env: - name: dev repo: dev scope: - scope1 - scope2 - name: prod repo: prod scope: - scope2 - scope3 I would like to process the file and extract ...
  • 99
-2 votes
0 answers
32 views

Create a script to invoke vi to find and delete lines in a file

I am trying to edit a file (file.xml) on a linux host using vi but I would like to script it. The goal is: vi file.xml /string_of_interest (search string of interest) dd (delete that line) :wq (write ...
0 votes
1 answer
31 views

Permission denied with locate command in Shell Script in Oracle Linux?

I am trying to run a shell script that contains the command $locate /etc/*.conf to find all files in /etc/ that end in .conf, but whenever I run the script the command line says /etc/chrony.conf: ...
  • 11
0 votes
4 answers
74 views

how to print first word from a string with multiple words without space?

I have a shell script to print appimage filenames inside a folder like this #! /bin/bash Dir="$HOME/Applications/" Dir2="$HOME/Downloads/" cd -P "$Dir" for f in *....
1 vote
1 answer
46 views

Simulating Keystrokes to a Telnet process

On my Linux system I have opened a Telnet session. On the other tab I am running a Python script and giving commands to the Telnet session using mkfifo file redirection. But I am not able to simulate ...
0 votes
1 answer
39 views

How to add time in my script

I have 3 scripts to build OpenWrt but I can't set it up to have time at the end. Here's what the script gives and the script. openwrt-snapshot-r22256+29-14334c222e-ipq806x-generic-linksys_ea8500-...
  • 97
0 votes
2 answers
66 views

Is it bad practice to use sed to pass a variable through to another script?

There are two shell scripts. One of which is a source file source.sh. This source file will exist for multiple people each with their own directories. name = "foo" The main script main.sh ...
  • 3
0 votes
1 answer
32 views

Shell script: How to prepend env variable with prefix only if environment variable is defined?

Given command that requires flag --flag. We want to insert this flag only when the value of the flag is provided as environment variable VALUE. I tried the following: echo "command ${X+--flag ${...
  • 379
0 votes
1 answer
60 views

how to make an already compiled elf file execute another command

I have a need for when a ELF file gets executed it will execute a command. For example: Running /usr/bin/file which is an already compiled ELF Binary, execute the command touch /tmp/file_is_executed ...
  • 83
0 votes
2 answers
26 views

get latest file on github via script

I am trying to do the same for https://github.com/eneshecan/whatsapp-for-linux/releases as is described here: Download and install latest deb package from github via terminal but cant get it to work, ...
  • 45
0 votes
0 answers
26 views

Where on earth could my startup tasks be?

Ok, for context: I once created a task to run a script whenever I boot my computer up and log in specifically as root. That was a while ago. I now want to remove that script from autostarting, but I'...
  • 89
0 votes
0 answers
38 views

How can I list all hosts on my network with the time and/or date that they connected to the network?

Regarding the situational context, long story short, a family member did a dumb thing, and I need to increase the capabilities of my network monitoring system. Is there a way to create a log of the ...
  • 89
0 votes
1 answer
90 views

Run a binary with arguments using absolute path

This is a embedded Linux system so things are a little different. I am trying to run an binary with arguments using absolute path but it doesn't work. If I run the binary from the folder it works e.g. ...
0 votes
1 answer
30 views

Run multiple instances of a script, with arguments, in parallel invironments

I have a script that connects to Openshift and launches a series of commands on PODs. Since I am working with multiple PaaS, I need to launch the script on each of them with a different connection ...
  • 3
0 votes
2 answers
85 views

Is there a command to copy and compile a c file to another directory?

Is there a command to copy and compile a c file to another directory? So if I have Ticker.c in the home directory, I want to copy it and compile it in another directory called Task
0 votes
2 answers
82 views

Set key with value on a line in a file, if not exists between specific lines, or set specific value

Given the following configuration file: shape { visible: true type: rectangle ... } shape { type: circle visible: isRound === "true" ...
  • 121
0 votes
1 answer
59 views

how do I handle a specific output from systemctl?

I am a beginner with bash/shell scripting and I am trying to handle a specific output that comes from systemctl when a specific service is not found. For example, when I run systemctl status xyz the ...
  • 3
0 votes
1 answer
91 views

put multiline variable value to a curl message in telegram

I want to send $log as a message in telegram using curl. It works when the variable value is one line only but I'm getting the error curl: (3) Illegal characters found in URL when its not (when the ...
  • 3
0 votes
1 answer
15 views

how to insert audio from video A into video B (no audio)?

Id like to create a video C with audio from video A but video from video B. Video A and video B have nearly the same length in seconds. Since the videos are a couple GBs, I guess it would be slower if ...
0 votes
0 answers
30 views

How to install scripts for machine translation using Moses-For-Mere-Mortals on Linux (VirtualBox)

I have installed VirtualBox on my computer, and Ubuntu by selecting Linux from the existing operating systems. When Ubuntu has started and I have downloaded Moses-For-Mere-Mortals from github . After ...
0 votes
0 answers
19 views

How to pause script/process execution, modify variable values, and resume script/process? (for a Linux distro installation process, if that matters)

I want to: Pause the execution of a Linux distro installer (running from an ISO on a USB flash drive), Modify the value of variables (that were initially read by the system from config files ...
  • 313
0 votes
1 answer
29 views

Why is it different to run bash with an argument vs with an input file redirection?

Why exactly is bash <script different than bash script? When i try this using a script that contains: cat hello world In the first case, i get what i expected: hello world But in the second case, ...
0 votes
2 answers
46 views

How to get the Path difference and store it in a variable

Suppose I have two paths. Path1 which is static and path2 which is dynamic. Example: Path1= /tmp/folder/ Path2= /tmp/folder/dir1/dir1_2 Result: Diff= /dir/dir1_2 I want to achieve as above example....
2 votes
1 answer
54 views

bash script about filter more keywords

Thanks for your time. I want to filter more than one keyword01 (keyword02, keyword03....) in the bash script as below. How can I get this ? All keywords alert to send to same E-mail address is OK. ...
  • 23
0 votes
1 answer
88 views

Installing the deb package as Service in Debian

I have a Deb package with set of binaries(.NET 6 based), but these application we need to install as a Service in Debian machine. I can able to do the service installation manually., Need some input ...
0 votes
1 answer
56 views

Unable to capture exit code of a script ran inside of a heredoc

I was playing around and got stuck while trying to capture the exit code of a script I'm running within a heredoc in a Docker container. Say I want to run this command to start a Docker container ...
0 votes
0 answers
16 views

Enter Ubuntu's VPN's credentials using CLI only, avoiding GUI

I spent days searching for a method to automate the process of logging in to Ubuntu's built-in VPN "Multi-protocol VPN Client (openconnect)", but I didn't find a way to do it, this is what I ...
0 votes
0 answers
19 views

Source env variable resolved instead of local env variable

I am having the following issue with Enviroment variables: In my linux server I have an enviroment variable HOSTNAME (has value SERVER_HOSTNAME) In my Linux box I have another enviroment variable ...
0 votes
1 answer
26 views

writing script The first parameter: file/directory,the other parameters: commands

I want to create a script that receives a list of parameters in the following structure: The first parameter: file or directory The other parameters: the names of the commands in the system, for ...
  • 19
0 votes
0 answers
20 views

how to assign sound effect to some keyboard keys

I use gnu+linux, and I need to assign an audio sound to the | keys, Imp pant and the mouse click only, for educational use, ¿how can I achieve that assignment if I'm user of the i3wm window manager?
0 votes
2 answers
46 views

How to combine files from incrementing directories into one directory

I have a directory structure that follows this kind of pattern: - Dir 01 (Disc 1) \ - Dir 01 (Disc 1).iso - Dir 01 (Disc 2) \ - Dir 01 (Disc 2).iso - Dir 01 (Disc 3) \ - Dir 01 (Disc 3).iso - ...
0 votes
0 answers
37 views

Redirect output to /dev/fd/x in POSIX script, where /dev/fd/x replaces process substitution

I have a would-be POSIX script that includes filtering the stderr output: exec <cmd> "$@" 2> >(grep -v "blih bluh blah") Redirection does not occur because process ...
  • 2,429
1 vote
3 answers
74 views

Writing bash arguments with trunctation

I want to print the first two arguments of a bash function, with the unicode character \u2263 on each side using a two space separation. The thing is that the final unicode must display at column 70. ...
  • 141
0 votes
1 answer
34 views

Listing mime-type for each input file

I want to pass a set of file names to a bash function, and list the mime-type as follows. video/mp4 file.mp4 video/mkv file.mkv Here is the loop iterating each file for fl in "$@"; do ...
  • 141
0 votes
1 answer
52 views

Text processing - Modify based off two different files

I have two files named one.txt containing "297","237","14",NULL,"51.195.14.201","02:00:00:1a:1c:06","255.0.0.0","10.0.10.1","...
  • 2,793
0 votes
1 answer
123 views

What's the difference between "sh command" and run as executable?

I used a script suggested by @Artem S. Tashkinov :"I've written this for myself but it runs on console." See related post here $sh raw_io.sh: 20: shopt: not found raw_io.sh: 48: declare: ...
user avatar
1 vote
1 answer
90 views

Why doesn't ampersand (&) work in string replacement without being escaped?

The following script is really simple, and replaces &amp; with &: string="Foo &amp; Bar" echo "${string//&amp;/&}"; But the script does nothing. There are no ...
  • 9,975
0 votes
0 answers
50 views

I can't concatenate ssh to a server from another server

I want to get the last folders name from a pi and this commands works just fine: ssh pi@192.168.6.24 'ls -t /media/usb/Pictures/new/ | head -1' Returns: 230125_1356 To retrieve the number of files in ...
  • 1
0 votes
1 answer
74 views

Is there a Guix equivalent of nix-shell shebangs?

I want to write a script which executes within a specific guix shell environment. I'm hoping there's an equivalent version of the nix-shell shebang. For example, it would be cool to write something ...
  • 120
1 vote
0 answers
50 views

Passing ffmpeg options to a bash function

Am writing a bash script where I can supply parameters for ffmpeg. What would be a good way to pass the parameters to the function? Using a string perhaps. script.sh "-aq 1" *.mp4 One ...
  • 343
1 vote
0 answers
65 views

Validate Variables in bash script

Below script is working fine with log getting generated. #!/bin/bash dir_to_check='/root/file_path.txt' CY=`date +"%Y"` TS=`date "+%Y-%m-%d"` cmd="/$CY" cat $...
  • 3,084
0 votes
1 answer
46 views

Script input data run commands based off it

Not sure where to begin I only know basic text processing. I am trying to create a script that will search for zfs snapshots based off a VM name (given as a command parametet) and then select the ...
  • 2,793
0 votes
0 answers
42 views

Move directory contents up one level only if it contains files

How to I move directory contects up one level only if it contains files. Some hints would help. Thanks! Example to move up one level: ├── AAA │ └── AAA1 │ ├── 001.jpg │ ├── 002.jpg │ ...
1 vote
4 answers
153 views

How to find out if pipe is broken?

I have a POSIX shell script which has its standard output 1 redirected to a pipe. At some point of the script execution, the pipe will break and I'd like to find out (in my shell script) when that ...
  • 2,260
1 vote
1 answer
31 views

Process name as the called executable, not the calling script

Edit: I relalised after posting the below that the machine where this 'worked' had in fact not been restarted and the running processes had been launched using an older scheme of actual aliases (...
  • 33
2 votes
1 answer
72 views

How to stop program of non-interactive SSH call without pseudo-terminal

Let's say I start a program with a non-interactive SSH call (without pseudo-terminal) and exit the session via CTRLC: $ ssh user@server -- sleep 123 ^C This way, the program, in this case sleep 123 ...
  • 2,260
1 vote
1 answer
48 views

Bash: Define a path that is above absolute path

I'm running a script in a directory: a/b/c/d/script.bash I need to create an environment variable, projroot, such that script=$(readlink -f $0) # Absolute path to this script. export projroot=$(...
  • 127

1
2 3 4 5
88