Skip to main content

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
21 views

Bash Script that zips a directory as "cert_$date.zip", then upload the zip file with curl to external server

I have a folder that I want to zip a directory, then upload it to a web server with curl. Backup folder: /opt/ladapter/data Zip File: /opt/ladapter/cert_$date_ymd.zip Bash script: cert_script="#...
Europa's user avatar
  • 213
-3 votes
1 answer
78 views

script does not work

I can successfully execute this command from the terminal: sudo cp -R -u "/media/gabriela/Windows/Data/Untitled Folder" /media/gabriela/USB But the following script does not work, with the ...
Gabriela Remow's user avatar
-2 votes
1 answer
89 views

Unexpected grep Messages During SSH Command Execution

When attempting to execute SSH commands on remote servers using grep within a Bash script, I encounter unexpected grep messages instead of the expected command output. error message : The issue ...
KaaaaaaaaaK's user avatar
-1 votes
0 answers
29 views

My clickable .sh shell script keeps opening in text editor and does not run the command when clicked [duplicate]

I am trying to write a script that when clicked runs commands. For example: "open browser and go to website" etc. etc. Here is what I have done: I have ran chmod +x test.sh on the file I ...
F41k0r's user avatar
  • 1
-1 votes
0 answers
31 views

Make shell script output correctly [duplicate]

I am trying to run a shell script to get the PID details and sort them based on memory, while executing in the server. I am getting correct output like this: [inda@jump-server ~]$ ps -eo pid,ppid,cmd,%...
Hari's user avatar
  • 1
1 vote
1 answer
34 views

expect_out(buffer) returns (buffer)

I have this strange behavior which i can't find anything on. expect -re "\$remote_cert_dir.+crt" { set last_cert $expect_out(buffer) } puts "after expect \$last_cert" Gives ...
Matte's user avatar
  • 11
-1 votes
0 answers
51 views

Top command - 100% cpu

I've been using a script to create a log based from information i can get in top and then report when my app is using too much resources, to retrieve the cpu usage i take the entire line %Cpu(s): 13.6 ...
Cesar Chavana's user avatar
0 votes
0 answers
28 views

Issue runing a background image changing script with crontab on reboot [duplicate]

Im trying to create a script to change the background image on startup. I created a file with this code: REAL_UID=$(id --real --user) PID=$(pgrep --euid $REAL_UID gnome-session | head -n 1) export ...
Xxale137xX's user avatar
0 votes
1 answer
70 views

Bash script doesn't work when used with keyboard shortcut, but works in the console

With the help of AI I made a script, which toggles between the two audio devices chosen by me. Since the name of the device changes on each system reboot, the script finds the devices by their ...
Ap0st0l's user avatar
  • 111
6 votes
1 answer
707 views

Should I use the "time" keyword, the "/usr/bin/time" command or the "times" builtin to time the execution of commands in bash?

I have been delving into bash for the first time and want to try to test some code to compare different ways of achieving the same end. As part of this I have come across the time and times methods of ...
dmkonlinux's user avatar
0 votes
0 answers
32 views

How to completely turn off the second screen on a ZenBook UX482 running Ubuntu?

I own a ZenBook UX482, which has a second screen. On Windows, there is a dedicated button to turn off, put to sleep, and turn on this second screen. However, after switching to Ubuntu (version 24.04), ...
alfafa's user avatar
  • 1
6 votes
3 answers
1k views

Can I get the location of bash before executing a script?

I have a stupid question. Can I get the bash location, such as "/bin/bash" or "/usr/bin/bash", before I execute the script? I tried to do this: #!`which bash` Or this similar ...
ilie alexandru's user avatar
0 votes
0 answers
47 views

Setting prompt using PS1 in a script puts cursor at beginning of line

I want to set the title and prompt in a command line window using the following command: PS1='\[\e]0;deploy\a\]\[\e[1;32m\]\u@\h\[\e[0m\]:\[\e[1;34m\]\w\[\e[0m\]\$ ' If it is entered interactively, ...
robin's user avatar
  • 1
-1 votes
1 answer
53 views

Re-write a zsh_lf snippet to work in zellij instead of tmux

I am trying to rewrite the code below (source): _zlf() { emulate -L zsh local d=$(mktemp -d) || return 1 { mkfifo -m 600 $d/fifo || return 1 tmux split -bf zsh -c "...
Muzzamil's user avatar
  • 101
0 votes
0 answers
45 views

Difficulty launching a VM at startup (24.04)

I've spent the past week trying to figure out how to run a VirtualBox VM on startup with no success. The command I'm running is VBoxManage startvm HAOS --type gui and it works perfectly when I run it ...
Matt's user avatar
  • 1
0 votes
0 answers
66 views

Trying to concatenate 2 bash variables doesn't work

Trying to concatenate 2 bash variables doesn't work. I've got the following script: #!/usr/bin/env bash echo Backup WSL bdir=/mnt/f/wslbackup/ echo Backup Dir is $bdir rel=$('/mnt/c/program files/...
Rich Guagliardo's user avatar
1 vote
0 answers
31 views

Asus TP500LA screen flipping issues

A little while ago i manages to pick up a Asus TP500LA off the side of the road and installed Ubuntu 20.04.6 LTS onto it. works great but the screen doesn't flip when rotated 360 degrees. what i have ...
Matthew Williams's user avatar
0 votes
1 answer
51 views

Recurring movement of complete files

I would like to address a query that may have been previously discussed or addressed indirectly through other inquiries. I am in need of a solution for recurrently moving files with a specific file ...
Luca Panareo's user avatar
0 votes
2 answers
89 views

How to execute scripts from a samba drive (cifs mounted)?

If I'm starting a shell script "test.sh" from a samba share, I've got an error: bash: ./test.sh: /bin/sh: Defekter Interpreter: Eingabe-/Ausgabefehler (bash: ./test.sh: /bin/sh: bad ...
dschoni's user avatar
  • 97
0 votes
1 answer
73 views

Bash script not launching correctly

Right now I am working on a project for which there is a custom conda environment. I created the environment and the project works, so I created a bash script to activate the conda environment, launch ...
Samuel Kostadinov's user avatar
0 votes
0 answers
29 views

In Nautilus, is there a way to make the 'Set as Background' button call a bash script?

Nautilus doesn't have this as a setting. When setting an image as background i get the error Failed to set wallpaper via portal: GDBus.Error:org.freedesktop.DBus.Error.UnknownMethod: No such interface ...
Bartek Masiak's user avatar
-1 votes
2 answers
100 views

I in linux system I geting many same exported path variable

In my ubuntu system I getting same env variable many times This is the output of echo $PATH | tr ':' '\n' | less command in zsh shell /opt/some/bin <<< /Users/pritam/Developer/system_script /...
Pritam's user avatar
  • 1
0 votes
0 answers
102 views

Ubuntu 22.04: Running a script at login - starting VPN

I have a script call startVPN.sh that I have put in the .profile file. If I run bash .profile, the script runs but it does not run at login. How do I fix this so that the VPN starts automatically at ...
A Basel's user avatar
  • 21
0 votes
0 answers
26 views

DIff output between 2 directories is printing the filename instead of the content

I have a directory named v1, with following tree v1 ├── a.json ├── b.json ├── c.json ├── d.json ├── CRESTReport # this is a directory i.e. v1/CRESTReport │ ├── crest.json │ ├── crest1.json ├...
Mihir's user avatar
  • 1
3 votes
1 answer
334 views

Is there a way to know if a file was copied?

I'm using Ubuntu 22.04, and I'm making a bash program (script) to run scripts at startup, shutdown and/or reboot. These things are sensitive and, if poorly done, it could be dangerous for the user/pc, ...
Carlos González's user avatar
0 votes
1 answer
419 views

Getting Error in shell script "unexpected EOF while looking for matching `''"

I wrote a simple shell script in /bin/sh and getting the issue below. /tmp/a.sh: line 14: unexpected EOF while looking for matching `'' /tmp/a.sh: line 17: syntax error: unexpected end of file *******...
Atul Jain's user avatar
0 votes
0 answers
51 views

Cannot switch into runlevel 4

I use Ubuntu Server 22.04.4 LTS. My task is to setup runlevel (target) 4 to automatically start ssh. I suppose I have found solutions how to do that and implemented that using script placed in rc4.d (...
Krecikkko's user avatar
-3 votes
1 answer
92 views

My shell script wont run, what did i do wrong? [closed]

#!bin/bash Awk -F" " '{print $1, $2, $5, $6}' Notes_Dealer_Schedule.txt > Dealer_Schedule_by_time.sh Var $1 Dealer_Schedule
jbob2711's user avatar
1 vote
1 answer
206 views

Are there limitation to how i can effect a terminal window title

New to bash scripting and looking to tidy my screen. I have a number of terminal windows running separate process but all with the same window title. Using the following i can change the title.. all ...
Paul Eden's user avatar
  • 169
6 votes
2 answers
859 views

Is there a way to use tee with the whole script from INSIDE the script?

I'm making a script to update the system (Ubuntu 22.04), updating all packages in apt, flatpak and snap with one order (like sudo ./update.sh) and, in case something goes wrong, I want to save the ...
Carlos González's user avatar
0 votes
0 answers
20 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
582 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
200 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
323 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
51 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
132 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
74 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
109 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
83 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
77 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
44 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
44 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
0 votes
2 answers
244 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
  • 113
-2 votes
2 answers
684 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
  • 51
1 vote
0 answers
47 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
33 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
100 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
88 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.4k
0 votes
0 answers
140 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
73 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

1
2 3 4 5
134