Questions tagged [shell-script]
A shell script is a script written for the shell, or command line interpreter, of an operating system.
1,446
questions
0
votes
0
answers
37
views
how to use curl for single sign-on website or page
I've already written a shell script but it's not working. I'm getting an empty response whereas it should first return a token and also it should login then register the API.
That's the task which my ...
1
vote
0
answers
20
views
Pathname or word too long in Cshell
I am using cshell. And I know that there is a limit of 1024 character while setting path. But I have many path variables which I need to set. So, it is exceeding 1024 characters and I am getting an ...
0
votes
1
answer
32
views
shell helper function wrapping `find` and ignoring some dirs
I have a bunch of scripts which follow the pattern of:
find files which match a pattern
do something
The problem is that there are several "hazard" directories which are large and slow, ...
2
votes
0
answers
106
views
How to quick record system audio in background on macOS?
On macOS Monterey I want to achieve what can be done on Windows with ShareX: record system audio with a global hotkey and have the audio file automatically copied to the clipboard – all in the ...
0
votes
1
answer
70
views
Why does zip --exclude only exclude files in the folder but not the folder itself?
I have the following command run in the bash shell which excludes the files in the folder scripts/. I tried the answer in Zip command for excluding directories and files but unfortunately it did not ...
1
vote
0
answers
44
views
Zsh handling of substring changed?
I have over a thousand directories holding MP3 files and text. I work on one directory each day, assisted by zsh scripts. I mostly use zsh on command line and in scripts. The paths are in the form ...
1
vote
0
answers
38
views
Grub script how to remove menuentries
I made a grub script to detect bootable disks and show them on grub menu. It is working but I want to put a rescan button and to make that first I need to remove old menuentries. How can I do?
My ...
0
votes
0
answers
107
views
TERM environment variable not set when running shell script using automator (MAC)
In using mac sonoma. I tried to run my shell script via Automator app. There's a 'diskutil umount' command in the script that will give me this error :
TERM environment variable not set.
Usage: ...
0
votes
1
answer
151
views
How to convert code from test format to if fi format?
I have code that opens a bash file in a terminal for entering the sudo password:
test "$IN_TERM" || {
export IN_TERM=1
konsole -e "$0"
exit 0
} && true
I need ...
3
votes
0
answers
180
views
Is there a good way to write a shell script compatible with both bash and zsh that addresses array elements?
The fact that bash is 0-indexed and zsh is 1-indexed can cause problems. For example the following will work as intended with bash, but not zsh (PS I am aware that I don't NEED to use an array for ...
0
votes
0
answers
20
views
Install a shell script with homebrew -- to install darktable (1_install_hb_dependencies.sh)
I want to build darktable from source w/ homebrew, like so: doc on Github. I have installed homebrew (step 0). Now I'm stuck at the first step where I need to install ''required homebrew packages'', i....
1
vote
0
answers
1k
views
Termux can't run shell script
As stated in the topic above, I am trying to configure a hardware using shell script which is downloaded from the official website of Orange Pi. Am using termux as the medium to run the shell script ...
0
votes
1
answer
82
views
Having disabled command-Q for Terminal via shell defaults command, how can I re-enable it?
I have a large, complex console program for execution via Terminal which solicits many responses from the user. Users may be habituated to use command-q to exit a program. This program has its own ...
0
votes
0
answers
273
views
ffplay works from command line but error with .sh script and systemd
(Originally posted as a generic question, then I found the ffplay forum)
I'm trying to set up a daemon to play short sound effects as part of an interactive wheelchair ride. (Due for installation next ...
0
votes
1
answer
84
views
How deep is too deep for Nested Folders in a Bash program?
I am somewhat new to Bash and am writing a program to install .NET SDK and Runtime on each of the available Linux distros.
The problem I am having is that I am trying to source functions from two ...
0
votes
1
answer
66
views
zsh on MacOS catalina 10.15.17
I'm having a little trouble putting this all together...
I want to make a simple shell script to organize and sort around 60 GB worth of music and movie files that are spread out over 3 or for 4 ...
1
vote
0
answers
199
views
Source multiple files in background/parallel (ZSH)
For various reasons I would like to be able to source a series of files in background and wait for them all to finish:
source ./my_file_1.sh &
source ./my_file_2.sh &
...
# etc
wait
But, ...
0
votes
0
answers
105
views
lftp in shell script fails with "pseudo-tty allocation failed" only when run via cronjob
I am trying to create a shell script which copies a file to a foreign server using SFTP (because SSH is not available on the foreign server). The script works as expected when run via console, but it ...
0
votes
0
answers
28
views
Programmatically open new CMD and enter code *but not run it*? [duplicate]
Is it possible in Windows to programmatically launch a new instance of CMD, Terminal, or PS (doesn't matter which) and populate the input field with some arbitrary code, just like if a user was typing ...
0
votes
0
answers
96
views
Perform lookup on two files
I have a csv file that get's SFTP'd to a RHEL box I have setup. It then gets transformed a little before another process SFTP's in and grabs it sending it off to be imported to a DB of a 3rd party.
I ...
4
votes
1
answer
164
views
Query effective ssh (client) config from the command line
Is there any way to query the effective ssh (client) configuration?
Specifically: can I determine e.g. whether there's an entry for a given host, what's the ProxyJump or User setting for that host etc....
0
votes
1
answer
61
views
Complex find statement
Have a script that I use to purge old backup directories. All the directories are named YYYY-MM-DD. The backup directories have links in them as the backups are incremental using the rsync --link-dest....
3
votes
1
answer
62
views
Is it possible to schedule "Alarms Only" mode in Windows 10 using a shell script?
I want to automate this to trigger every day at certain intervals, it seems so hard to configure a good notification system in Windows 10.
I would like to trigger the Windows focus "Alarms only&...
1
vote
1
answer
381
views
Maintain a fixed-size-queue of nohup jobs
Suppose I would like to run multiple nohup jobs but at each time I would like to at most run 4 nohup jobs.
Is there a way to:
keep track of 4 nohup job status
once one of them finishes, it triggers ...
2
votes
1
answer
118
views
Algorithm to find longest common substring
I'm having a bit of trouble coming up with a general solution to the following problem.
First a bit of context.
End goal: set file permissions on all files and directories created by a rpm
My plan was ...
0
votes
0
answers
698
views
Reference shell Script within a shell Script in YAML
Is there the right way to reference a shell script written within a script in a YAML file. For eg:
data:
ex1.sh: |
#!/bin/bash -x
. /shellscriptloc/ex2.sh
...
...
2
votes
0
answers
45
views
SFTP user login details real-time filtering
I have enabled the SFTP login log into the default logfile /var/log/syslog and tried to filter the login time of each user and insert it into the database.
But the filtering is not worked as I ...
0
votes
2
answers
289
views
Bash printf: what does format specifier %P mean?
The printf statement :
find directory1 -type d -printf "%P\n" | sort > file1
in the answer https://superuser.com/a/166322/856910 includes a format specifier %P. From the output of this ...
0
votes
0
answers
594
views
how to print an entire get request from an API in Powershell?
I am working on a powershell script that displays all of the dns servers I manage via GoDaddy, and see which ones are about to expire. I am using the GoDaddy API and this following code:
. .\configs\...
0
votes
0
answers
15
views
How can I read input directly from the terminal instead of stdin [duplicate]
TLDR; I want to read a user input directly from the terminal leaving stdin untouched.
context
I'm writing a shell script that handles user passwords (verifying strength and authenticating other apps).
...
0
votes
1
answer
456
views
Running shell Script via Systemd.timer
So I've essentially run into the same problem as in my other question: Running shell Script via Crontab
I will now run my shell script with systemd.timer but it is not working so far.
Here is my ...
1
vote
2
answers
394
views
How do I run a bash script automatically everytime I hit CTRL + S?
I'm making frequent changes to a bash script and everytime doing "./demo_script.sh" is repetitive.
Is there any way that it can automatically execute as soon as I hit CTRL+ S on keyboard?
2
votes
2
answers
201
views
Why the variable doesn't change even if it should?
I have this bash script:
#!/bin/bash
someVar=0
tac /etc/hosts | while IFS= read line; do
echo "$someVar : $line"
someVar=$((someVar+1))
done
echo "Finally: $someVar"
...
-1
votes
1
answer
740
views
I would Like to know what -sb and awk '{print $1}' role in this command
subdirectory_size=$(du -sb "$entry" | awk '{print $1}').
I would Like to know what -sb and awk '{print $1}' role in this command.
1
vote
2
answers
1k
views
Change the default location of zsh completion cache files for macOS
I'm trying to change the default location of the zsh completion cache files in macOS. I have read the zsh documentation on completion which say's "alternatively, an explicit file name can be ...
0
votes
0
answers
89
views
How to automate mybb installation using ssh bash script
I have created this bash script to install mybb application automatically on Centos stream 8.
SSH Bash script
#!/bin/bash
# Define variables for MyBB installation
DB_NAME=mybb_db
DB_USER=mybb_user
...
2
votes
2
answers
113
views
What options are being used by sed to parse a file and write to new file
I am debugging a LINUX script that was written by someone else. In the script we have a line of code like below
sed -i "\#</resources>#{h;s#.*#cat /opt/abc/new.xml#e;G}" /opt/abc/...
1
vote
1
answer
253
views
Can't input text in Bash function called with key binding
I have added a simple function to my .bashrc file and bound it to a key combination using the bind command. The function prompts the user for input using read, like this:
myscript() {
read -p &...
1
vote
1
answer
255
views
Batch rename movie folder(s) to movie file inside of folder?
I would like to rename my movie folder names to match the movie file name inside the movie folder. The movie files have the right names but the folders do not.
I've found batch file rename options for ...
1
vote
2
answers
608
views
Batch processing stdin lines with Windows batch .bat script
I have a Windows batch script delete.bat with that contents:
@echo off
takeown.exe /A /R /F %1
icacls %1 /grant Administrators:(OI)(CI)F /C /T /Q /L
rmdir /S /Q %1
echo %cd%\%1 >> "C:\...
0
votes
0
answers
213
views
Sftp credentials working in winscp but not in command line
I have a windows server which I also log into via putty. On the windows server, i have winscp with saved and working logins. From winscp > Generate Session URL, I can get a specific accounts login ...
0
votes
1
answer
95
views
How to highlight text using color in output if in a certain temp range
I am outputting the HDD temps of my system to a text file on a local webserver that I can check every once in a while to monitor hdd temps when the system is under load. I was wondering if there is a ...
-1
votes
1
answer
474
views
Confused on how to use mkdir with shellscript
I'm trying to create a program that recursively makes folders for fun and I'm having trouble using mkdir. When running it in terminal it gives back these error messages:
./folder.sh: line 6: syntax ...
0
votes
1
answer
347
views
Powershell: sorting directories based on file count
I am attempting to create a list that counts the number of files in a folder and then sorts the order of the folders based on that count. I have the following but it doesn't work (i.e. doesn't sort):
...
1
vote
1
answer
1k
views
How to execute "source" command inside a shell script and then store the output of source in a variable within the shell script?
I have written a shell script (called profile.sh) to fetch temperature values from the Android MPSoC. Separately, I have found a shell script that fetches the FPS of an app on the Android system as ...
0
votes
1
answer
128
views
Script to add a tag at the end of files in a folder in case that tag is missing
I'm struggling with a shell script. I have a bunch of xml files, more than 500, and some of them has no end tag </deliveries> I created a shell script that works but only if I write the filename ...
0
votes
1
answer
126
views
Geany – display file path line
I’m a new Geany user. I code shell scripts on Linux.
How to display "files path line" like this Geany image below ?
I can't find any options in the Geany settings.
Do I need to install a ...
-1
votes
1
answer
146
views
Powershell infinite loop and returning unexpected results
Script
PS C:\folder>$a=@(100,001,10,101,002,11)
$arrayCount=$a.count
for ($i=0; $i -le $arrayCount; $i+=3) {
$oldNumber=$a[$i]
$oldNumber="{0:d3}" -f $oldNumber
$newNumber=$...
0
votes
2
answers
3k
views
Is it possible to remove cURL command?
I am a new Tier2, Tier3 is requesting I attempt to write a script to remove the curl command from student PC's, is this possible? Should I suggest disabling curl via AD group policy?
1
vote
1
answer
376
views
How to find the "pattern" in FASTA file and record the cordinates along with header
I am looking for a solution to search for a string of 17 base pairs in the FASTA file that is the human reference genome.
To clarify, in simple words and put the resources, i have tried grep function ...