Questions tagged [scripts]

A script is a program or sequence of instructions written in a plain text file. The script interpreter (for example Bash, Python, Perl etc.) reads the file and carries out the instructions as if they had been entered at the command prompt. Use this tag for all questions related to creating, troubleshooting and running scripts.

Filter by
Sorted by
Tagged with
0 votes
0 answers
24 views

How to run executable .sh file by double-clicking it in Zorin OS 17 / Ubuntu 23.10? [closed]

I want an sh bash file on my desktop that I can run by double clicking it, but my attempts to search for answers to this problem are outdated. There is no option in Nautilus preferences, dconf-editor, ...
ubuntu's user avatar
  • 103
0 votes
0 answers
19 views

Shell script doesn't recognize Python even after setting its path [duplicate]

I'm having trouble calling Python code from a shell script on Ubuntu. First of all, I confirm that Python is installed: username@Ubuntu22:~/Documents/Script$ python Python 3.10.12 (main, Nov 20 2023, ...
Ogiad's user avatar
  • 1
2 votes
2 answers
435 views

How to replace a file path with whitespace using sed?

I have many different files with a string in them. I need to replace this string with a path, although the path contains whitespace. So far, I have this: for a in files_[a-z][a-z]_all\.conf ; do ...
Spaghetti's user avatar
0 votes
2 answers
65 views

echo command not working when used inside find block

I have this in my linux script: find . -name '*.xml' | while read MYXMLFILE; do echo "Checking $MYXMLFILE" sleep .5 .... .... fi done But I see that echo doesn't do anything ...
Mandroid's user avatar
  • 133
2 votes
2 answers
103 views

How do I enable script in etc/rc.local to run on startup?

I have a script I want to run on startup (this is for a raspberry pi), and I've followed the instructions in the answer to the same question (linked here). The code I want to run is in a text file ...
user23815104's user avatar
1 vote
0 answers
44 views

Script used to find and split the chapters between 2 and 6 (x and n) of all m4b files in directory

I'm trying to use a script to find and split the chapters between 2 and 6 (x and n) of all m4b files in directory. This code splits m4b files out into chapters when run bash m4b-split.sh *.m4b #!/bin/...
Rick T's user avatar
  • 2,223
0 votes
1 answer
87 views

Correcting #!/bin/env python shebang issue

I recently installed DOCK3.7 on my workstation running Ubuntu 20.04. However, I encountered an issue where the python scripts called upon could not be located, despite specifying the correct path and ...
Anthony 's user avatar
0 votes
0 answers
33 views

set: pipefail failing on WSL windows

I cloned this repo on WSL2 https://github.com/apache/airflow/blob/main/dev/breeze/doc/01_installation.rst#docker-in-wsl-2 and tried to build a docker image that uses also this script https://github....
criss's user avatar
  • 1
0 votes
0 answers
75 views

How to start a named background process when using bash?

I have a script that looks like this: #!/bin/bash tsx watch services/$1/src/index.ts This will start tsc for the given service: script/start_service some-service If I add & the end it gets ...
Adam Arold's user avatar
0 votes
0 answers
33 views

Script ideas for configuring VPN connection

After some bad crashes of my system, I decided to take a more organized approach and develop a bash script that will handle most of the things I tend to configure manually after a fresh installation (...
Jimakos's user avatar
  • 353
0 votes
0 answers
20 views

How to find the Disconnected Xrdp sessions?

I'm using Ubuntu 22.04 with Xrdp enabled. I need a list of disconnected sessions (Users can often use the "X" to close the RDP session (therefore disconnect but not logout)). I went through ...
SIVA KUMAR KALLURI's user avatar
0 votes
0 answers
29 views

unattended bash script (*.sh) with password

I want automatically made full image backup from any servers. Manually it works like: ssh [email protected] "nohup sudo -S dd if=/dev/sda | gzip -1 -" | dd of=fullServerXX-`date +%d%m%y`....
Pythonaire's user avatar
0 votes
0 answers
41 views

here file does not fill token

I use a certain command quite frequently, but the command prompts a few things so I wanted to auto-fill it with here file, but it seems that for some reason it can't provide last value to the prompt. ...
Bartosz Wichowski's user avatar
-1 votes
0 answers
51 views

Variable returning empty in logon script

I'm trying to make a script that runs when the user logs in, to change the wallpaper. I run the script at logon, the script is inside the /etc/profile.d/ folder. I use ImageMagick to write the PC name ...
Raphael Aracelli's user avatar
0 votes
2 answers
131 views

How to write a bash script from two commands (Find and replace a text string in all files recursively in current directory)

On Ubuntu Server, I use two different commands to find and replace a string in all files recursively in the current folder. The first command is: sudo find . -type f -print0 |\ xargs -0 -r sudo ...
DanRan's user avatar
  • 95
-1 votes
1 answer
150 views

Is there an easy way to install Session messenger on Ubuntu/Whonix

Session messenger https://getsession.org is great, yet for some releases of Ubuntu and for Whonix in particular the installation is way too frustrating. In particular Both Ubuntu and Whonix don't ...
Igor's user avatar
  • 55
1 vote
0 answers
36 views

How to add my own shell script to be able to be autocompleted in terminal by Tab

I have bunch of shell script (.sh) command created in a folder ~/bin, I added this path to .bashrc so I can execute them wherever I like. i.e. a sample command to create git feature branch based off ...
Dreamer's user avatar
  • 111
0 votes
0 answers
27 views

Monitoring user activity restricted to GUI apps

I wish to monitor what all apps were opened on the PC at any time. I mostly use it for operating GUI apps like chrome, vlc media player, etc. Specifically, I would like to know which app I opened at ...
IamThat's user avatar
  • 101
0 votes
0 answers
93 views

How can I run different commands in separate terminals using a shell script?

I have access to an Azure VM where I intend to run three Hyperledger Besu nodes: one boot node and two validator nodes. To automate this setup, I've created a shell script. First, I checked the ...
Shalabh Negi's user avatar
0 votes
1 answer
71 views

Backporting: Does anyone have a function to mimic bash 4 associative array?

I need to make changes in my script that uses associative array, so that the script may be used in older versions (before v4.0) of bash which did not support associative array. Can someone suggest how ...
rusty's user avatar
  • 16.3k
0 votes
0 answers
67 views

Transfer latest file from SFTP to Local

I am using the following script to transfer the file from SFTP to local machine. Is it possible to update this script to only transfer the latest file from the SFTP? Some examples Database.bak Copy of ...
mouzzampk2014's user avatar
2 votes
1 answer
50 views

Download and Remove the files from SFTP server

I am using this to download the file from remote server but could you guide how can I use one command to first download and then remove the file from server. sshpass -p password123 sftp User@sft....
mouzzampk2014's user avatar
0 votes
0 answers
96 views

how to install apache flink on wsl2 ubuntu of windows 11

Below is my Apache Flink Installation process on wsl2 ubuntu of Windows 11. First, openjdk-11 installation $ sudo apt update $ sudo apt upgrade $ sudo apt install openjdk-11-jdk systemd installation, ...
Joseph Hwang's user avatar
1 vote
1 answer
150 views

Problem writing udev script to disable onboard network card

I'm trying to disable a faulty onboard network card with the solution suggested in this answer: https://unix.stackexchange.com/a/467085 . But for some reasons, the script/commands are unable to write ...
rusty's user avatar
  • 16.3k
2 votes
3 answers
625 views

File removal on power off

I'm using Ubuntu 22.04LTS. I would like to create a folder "temp" where during my session I save the files that are, as the name suggest, temporary. How can I define a scritp that at ...
Iano's user avatar
  • 23
0 votes
0 answers
20 views

Bash script for executing linux commands on remote machines using ssh key [duplicate]

I want to run a script to get details of hardwares and user details from multiple remote machines by login using ssh private key. this is my script #!/bin/bash # Check if the user provided a file if [...
Subash's user avatar
  • 66
0 votes
1 answer
229 views

Script to notify via email when low on disk space

I found the below mentioned script on the internet, which notifies via email when server gets low on storage or as per defined. I run it every 5 minutes, if i am low on storage it keeps notifying me ...
Blohsh's user avatar
  • 3
2 votes
1 answer
125 views

Cron not running script on boot

The main idea is to make my pc run a script on boot in wich x11docker takes care of lifting a container with a youtube video. this is mi crontab -e: @reboot /usr/local/sbin/script-exo.sh script im ...
ømen's user avatar
  • 21
0 votes
0 answers
116 views

AWK issue on Bash script

I need to shortlist the logs between the particular timestamps. I can achieve it by using the below command. awk '$a>="Feb 5 10:44:*" && $a<="Feb 5 10:54*"' /var/...
Arunkumar NKL's user avatar
0 votes
1 answer
116 views

sed mongodb connection string copying multiple times in env variable through github action

this is command which i run in github action its copying into .env.production file sed -i "s#DB_URI=.*$#DB_URI=mongodb+srv://xxxxxx:[email protected]....
DevOPs's user avatar
  • 11
1 vote
0 answers
55 views

Script in /etc/ssh/sshrc ignore for one user

As I've read on couple threads, I configured a script in /etc/ssh/sshrc for it to send an E-Mail every time when somebody connects over SSH. That works pretty good but recently I started using ansible ...
NASH7's user avatar
  • 13
0 votes
2 answers
189 views

Setting DEBIAN_FRONTEND remotely

Is there any way to set DEBIAN_FRONTEND=noninteractive when executing a script remotely via SSH? Doing so I get this error: sudo: sorry, you are not allowed to set the following environment variables: ...
Socrates's user avatar
  • 2,493
1 vote
1 answer
154 views

Ubuntu 22 shell scripts on desktop open in text editor instead of launching

I have some shell scripts (files *.sh) on my Ubuntu desktop, eg. startdoublecmd.sh or startlazarus.sh. When using Ubuntu 20, those scripts started automatically upon double clicking on them. Now I ...
tk_'s user avatar
  • 121
0 votes
2 answers
85 views

How to monitor particular command or add extra functions to it?

I am attempting to implement mobile push notifications (utilizing the Docker ntfy service) for scenarios such as automatic system updates and Timeshift snapshot creation. None of these commands are ...
zawier's user avatar
  • 13
0 votes
2 answers
305 views

cron unable to run .sh script - 22.04

I am trying to run a simple script that checks the battery percentage and shows it through a notification (notify-send). The script runs correctly if ran from terminal manually: ~/path-to-script/...
overmach's user avatar
0 votes
0 answers
52 views

Running a script when switching Ubuntu user accounts

I have some software that is using absolute paths and is thus dependent on the user name of the account in question. I would like to run a script that is creating symbolic links in order to allow that ...
Leigh K's user avatar
  • 303
0 votes
0 answers
59 views

How to autostart a jar file with swing GUI when booting Ubuntu

I'm trying to autostart a jar file with an .sh script: #!/bin/bash export DISPLAY=:0 java -jar /home/username/Desktop/jarfile.jar The jar file is a Swing GUI application. When i manually start the ...
Daniel Tscherkaschin's user avatar
-3 votes
1 answer
83 views

Bash Script, Automated no and yes [duplicate]

I need to have a script that instructs the system to run an fsck on a drive but I only want it to run if the drive is not mounted "/dev/mmcblk0p2 /mnt/Share ext4 defaults 0 2" Basically is ...
Christopher Lock's user avatar
0 votes
0 answers
376 views

SyntaxError: Missing parentheses in call to 'print', while trying to run system

I am trying to run my system (Empire PowerShell), but it keeps giving me a syntax error. The system I used didn't support python3, so I had to install python2 which ended up working. But when I try to ...
Seul's user avatar
  • 1
0 votes
0 answers
54 views

Linux shell script getting "stuck" during network interface reset

I'm working on a linux shell script to aid in resetting network devices on my system is a bit speedier way than typing 5 commands. The problem is that the script gets intermittently stuck and returns ...
John Aldrich's user avatar
0 votes
0 answers
122 views

How to run password with sudo command using php?

Below is the example, I was trying to execute the command using PHP function. Not getting any error or not happen anything after execute this code. $siteConfig = <<<EOL server { listen 80;...
Urvin Sanghavi's user avatar
0 votes
0 answers
118 views

I need to run a script during first boot and want the CLI to open for possible input

Edit: I need a bit more explaining here. This is a one time only run personalization script for the computers that I have set up that I would like to run only on the first boot. After tweaking the ...
BuddyBoy's user avatar
0 votes
0 answers
65 views

Ubuntu Core - Startup Interactive Script

I have a fully supported device which I boot using an Ubuntu 22 Desktop image and "Try" it. Then I run the xzcat / dd commands to flash Ubuntu Core 22 onto the disk. Then I restart the ...
Pasha Siraja's user avatar
0 votes
1 answer
236 views

Why does my powershell script run with "pwsh" but doesn't with "sudo pwsh"?

I'm still somewhat new to Ubuntu / Linux so please bear with me if I'm not using correct terminology. I'm on Ubuntu 20.04 but I use Putty to perform everything via the terminal. I'm using a collection ...
tl6277's user avatar
  • 1
0 votes
0 answers
969 views

How to reload .bashrc settings without logging out and back in again?

I created a script that add's the below commands to the .bashrc file. The purpose is I need to store the commands entered by the user into the .bash_history. The below commands are adding to .bashrc ...
SIVA KUMAR KALLURI's user avatar
0 votes
1 answer
135 views

How to make my script that has a timer to shutdown my machine work?

I have script to shutdown my computer after 2 minutes, and 1 minute before shutdown it sends a notification that says "It will shutdown after 1 minute". The script will be executed on click ...
Web Developer's user avatar
0 votes
0 answers
37 views

How to batch rename a bunch of files of same type inside folders to that the numbers in the name are inside brackets? via terminal

Ubuntu 20.04 I have files stored in the following fashion as a example: Uni - Biology - 01122023 Class 01 - subj dfsg.txt 02122023 Class 02 - subj eweg.txt 03122023 Class 03 - subj ewq.txt ...
Kaikidan's user avatar
1 vote
0 answers
51 views

Jack not loading all the settings at startup

I can´t make my system recall the whole audio configuration at startup. After playing a lot with Jack, Carla and scripts, I've found this way to make my system (manually) work: Here is a little video ...
Javier Tucat Moreno's user avatar
1 vote
1 answer
141 views

How to identify the input that caused a program to segfault?

I have scripts that run programs (that I did not author) and some are getting segfaults on a few inputs. I do these things in large batches that run for up to a week, and would like to know which ...
ForDummies's user avatar
-3 votes
1 answer
244 views

Auto Script Generator

I want to generate a script for hard disk partitions #!/bin/bash # Check if blkid is installed command -v blkid > /dev/null 2>&1 || { echo >&2 "blkid is required but not ...
Mohsin Rao's user avatar

1
2 3 4 5
134