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.
6,658
questions
0
votes
0
answers
14
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`....
0
votes
0
answers
39
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. ...
-1
votes
0
answers
49
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 ...
0
votes
1
answer
82
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 ...
-3
votes
1
answer
41
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. Any easy way to solve the problem?
1
vote
0
answers
32
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 ...
0
votes
0
answers
24
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 ...
0
votes
0
answers
85
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 ...
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 ...
-2
votes
0
answers
163
views
Best practice to create a single panel button to process a file with awk, save it, then edit the output
In Ubuntu, what is the best practice to create a single panel button to process a somewhat large 15MB text file via awk, save that output with the same filename, and then open that file with a text ...
0
votes
0
answers
44
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 ...
2
votes
1
answer
33
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....
0
votes
0
answers
62
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,
...
1
vote
1
answer
133
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 ...
2
votes
3
answers
590
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 ...
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 [...
0
votes
1
answer
126
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 ...
2
votes
1
answer
119
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 ...
0
votes
0
answers
108
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/...
0
votes
1
answer
84
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]....
1
vote
0
answers
53
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 ...
0
votes
2
answers
129
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: ...
1
vote
1
answer
94
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 ...
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 ...
0
votes
2
answers
164
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/...
0
votes
0
answers
50
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 ...
0
votes
0
answers
51
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 ...
-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 ...
0
votes
0
answers
222
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 ...
0
votes
0
answers
50
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 ...
0
votes
0
answers
103
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;...
0
votes
0
answers
92
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 ...
0
votes
0
answers
46
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 ...
0
votes
1
answer
169
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 ...
0
votes
0
answers
577
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 ...
0
votes
1
answer
121
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 ...
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
...
1
vote
0
answers
39
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 ...
1
vote
1
answer
117
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 ...
-3
votes
1
answer
236
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 ...
0
votes
1
answer
166
views
Run a command using system.service ./start start
I'm trying to get my system.service file to run a command that is inside my start script. I've tried adding StandardInput= which did not work, so I believe I misunderstood how that operates. I've also ...
1
vote
1
answer
81
views
Bandwidth rate for specific IP (bash scripting)
I can watch live bandwidth rate using tcptrack -i ens3 src or dst IP
But I need to use it in bash script
Are any tools which could return current bandwidth rate for given IP?
Like in tcptrack in the ...
0
votes
1
answer
174
views
How to use invert match regex in sed? like grep
How can I use invert match regex like grep -v ?
I want invernt
sed '/[Ss][0-9]*[Ee][0-9]*/d' ${Src}
like
grep -ev '[Ss][0-9]*[Ee][0-9]*' ${Src}
1
vote
2
answers
205
views
How to make script work to set IP address of ethernet adapter?
On Ubuntu 22.04 I have the following script
#!/bin/bash
INTERFACE="enx00e04c681730"
echo "Interface: $INTERFACE set to IP $1"
ifconfig $INTERFACE down
ifconfig $INTERFACE $1 ...
5
votes
1
answer
365
views
What is an example use for a non-interactive login shell?
I understand it is extremely rare and the concept, but can't think of a use for it. I do have an idea that we may want to execute a script that has a command to login to a server through ssh, is that ...
1
vote
0
answers
19
views
Total keyboard, mouse and screen lock
I want to make an alarm script to play a video and lock totally the keyboard, the mouse and the screen until the video finish.
I really need wake up on time and sooner haha
This is all I have:
#!/bin/...
6
votes
2
answers
257
views
Find duplicate case insensitive filenames in all folders and sub-folders
I have about 250,000 files in several folders with sub-folders.
Looking for a solution how to find duplicate filenames in all folders and their sub-folders. My OS is Ubuntu 22.04, using bash.
I prefer ...
1
vote
1
answer
69
views
Dolphin context menu exec command, cp will duplicate selected folder if already copied
So I'm trying to automate some tasks and I'm making some dolphin ServiceMenus.
Exec=for file in %f; do new_path=$(echo "$file" | sed "s|^/home/$(whoami)||"); mkdir -p ~/Dropbox/....
-1
votes
1
answer
175
views
Does the Nano edited file not get updated after reboot?
I am using the nano command to update the file and save it, however, the file has not taken effect after the system rebooted. The file was not updated after checking again. Nano editor version 6.0.1, ...
0
votes
1
answer
66
views
How can I create my own app package?
I will give an example:
There is .deb, .appimage, flatpak, snap, AUR, etc, but I want to create my own (Example app.fictionalpackage)
Maybe zipping a folder with files inside and renaming ".zip&...