All Questions
517
questions
0
votes
0
answers
201
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 ...
2
votes
0
answers
260
views
How can I close a browser window from a bash script?
I would like to open and close windows from a bash script but in my two versions of the code it gets stuck when it opens the first window and does not close the current window and then open the new ...
0
votes
0
answers
27
views
How do I install many lines of packages with apt (from a script)? Does '\' work? [duplicate]
A part of my Bash script looks like this:
apt install -y alsa-base alsa-utils apt-transport-https build-essential curl ffmpeg geany gcc \
gnome-screenshot gnome-terminal libfuse2 libreoffice-calc ...
0
votes
1
answer
411
views
mv in script eports "cannot stat"
I'm trying to write a script that adds the last accessed time to the end of the basename. Here is the script:
for f in *.doc; do
DIR=$(pwd)
FILENAME="$f"
FILETYPE=${FILENAME##*.}
...
1
vote
0
answers
348
views
Creating a script for Windows 11 to gzip some files using 7-zip then move and replace them in another folder
I have the following directory structure:
Parent Folder: Project
Children of Project: data, rawData
Inside of rawData I have: index.html, settings.html, user.html, script.js, style.css and other files....
1
vote
1
answer
280
views
How to execute three terminal scripts in three new tabs from Applescript?
I have the following apple script top execute three commands in different terminals. Is it possible to (1) combine this script to make it more efficient and (2) open in different terminal tabs instead ...
1
vote
1
answer
123
views
When using script for WinSCP it opens another folder
I am trying to automate process of downloading files from SFTP server using WinSCP.
But I am having issues with the execution of one part of the code.
When the connection is established instead ...
0
votes
1
answer
204
views
Double-clicking .sh file on KDE fails to run the script
I have a simple .sh script on my Desktop that fixes a minor annoyance with my second display. If I open Konsole, and type ./script.sh, it runs perfectly. But if I double click that .sh file - it fails ...
0
votes
1
answer
191
views
Linux RHEL 7 - Shell Script - Can execute command separately but cannot execute inside a script
I have a simple script use to install a package under cust privilege like this (command changed for security)
installScript.sh
#!/bin/bash
patch -i <package-name> << EOF
n
EOF
the purpose ...
1
vote
1
answer
772
views
curl only works with -u but not with -n
I can't get where is the error
This works like a charm:
~$ curl -u '[email protected]:123' imaps://imap.mail.yahoo.com:993 -X 'STATUS INBOX (MESSAGES)'
But this don't:
~$ curl -n imaps://imap.mail.yahoo....
3
votes
0
answers
1k
views
I wan't to configure Windows Powershell Script execution policy precisely
Is it possible to configure the Powershell execution policy to ask the Administrator for authorization each time a Powershell script wants to run?
Something like this :
Windows Administrator ...
1
vote
1
answer
827
views
Can I and how to use `script` in a bash script
This must be the most frustrating research I've ever attempted (so far). So, there is script(1). I've been trying to add it to the start of a bash script I have (I was looking for a way to log every ...
1
vote
1
answer
137
views
stopping ssh process that is sent to background without corrupting stdout
My script aims to extract a text log file using tail -f and a wireshark trace using tshark. But I don't know if these are the best options for my goal.
My script has to ssh into a machine (which I ...
1
vote
1
answer
137
views
Why is this dot command behaving differently from the source command for the same script?
According to bash man pages and other online sources, the source command and dot should behave in exactly the same way when sourcing an existing script, but that is not what I observe. Consider this ...
0
votes
1
answer
294
views
Need to iterate Backwards in a linux/unix path
I have a script that would have multiple paths (folder names).
Each folder path would have a Dockerfile, but its uncertain at what level that file would exist.
Lets say my path is "v1/airflow/1....
0
votes
2
answers
178
views
exit from entr inside script
After some googling, I found the entr utility to run a command on a file update. I can get it working, but unfortunately, I'm unable to exit from it.
The literature about it isn't much and quite vague ...
1
vote
2
answers
815
views
Shell script in Mac Automator won't work with folders
I am creating a service in Mac Automator which is basically a bash script to change some dcm files with dcmodify. Whenever I run it on a single file it works flawlessly, but when I try to run it over ...
1
vote
1
answer
983
views
Reload user's group in a script
I'd like to create a new group in a script, assign the current user to it, reload the user's groups and continue executing commands that require the new group.
In this related question I found nice ...
0
votes
1
answer
2k
views
Powershell: Auto press enter every 5 minutes during script execution
I have a scheduled task running every morning that takes a bit to run (about an hour). During the execution of the script, I notice that the progress bar for it will stall randomly until I focus the ...
0
votes
2
answers
746
views
How to programmatically disable OSX from charging?
How can we programatically disable OSX from charging when connected to power source?
And how can we programatically check the current battery percentage?
In order to extend battery life I'd like to ...
1
vote
0
answers
1k
views
Bspwm is not working
I have installed Bspwm from AUR on my EndeavourOS distribution which was initially running the GNOME desktop environment.
I followed all the instructions on the Arch Linux wiki for Bspwm. I have made ...
0
votes
1
answer
462
views
windows 10 tries to run shell scripts from "C:\Windows\System32" directory
I have some bash scripts that I wanted to use like batch files in windows 10 by double clicking and let it to finish the job. Problem is it starts the script from windows system (C:\Windows\System32) ...
2
votes
4
answers
2k
views
Run bash scripts without typing the file extension the right way
I'm on Windows 10 and decided to transition from cmd to Git Bash. Say I have a script foo.sh, I'd like to be able to run it with the command foo and not foo.sh. I found this answer, which works in ...
4
votes
1
answer
3k
views
How to always execute a command when a shell script function finishes?
I need to write a zsh function with multiple exit points and execute the same clean-up command at every one of them:
function foo {
if ... ; then
...
run_cleanup
return
...
1
vote
2
answers
149
views
Running the script does not provide any result
Hello! I am a beginner who is trying to learn bash scripting. I would like to read the user input (hash) using my script. However, when I run the script it just hangs without returning any result. ...
0
votes
1
answer
334
views
Create desktop shortcut for Safari to a specific web - on MacOS
I'm trying to create a desktop shortcut for Safari that will lead to a specific website when the users will use it. Trying for hours but with no success. Can someone help please?
Thanks
1
vote
0
answers
1k
views
Is the macOS/Linux shell the same thing as Bash?
sorry if this is a silly question, but are there any differences between Bash and the macOS/Linux shell? (not all Linux distros use the Bash shell right?)
0
votes
1
answer
1k
views
Escaping quotation marks in a bash script on macOS
I want to turn the following command:
$ gdate --date='TZ="America/New_York" 1am' +"%a %F %H:%M %Z"
into a script using parameters, such as:
#!/usr/bin/env bash
gdate --date='TZ=&...
1
vote
1
answer
742
views
/bin/sh: TexturePacker: command not found (while zsh works) macOS Monterey
I have a small Adobe Animate extension that uses TexturePacker to pack sprites onto sprite sheets. I've successfully added TexturePacker to $PATH (/Applications/TexturePacker.app/Contents/MacOS) so it ...
1
vote
3
answers
1k
views
BASH Loop Through Variables
If i have a bunch of variables in bash, like this:
foo_1="path/1"
foo_2="path/2"
foo_3="path/3"
foo_4="path/4"
foo_5="path/5"
They all start with ...
0
votes
3
answers
116
views
Using --my_argument `cat some_file` as argument to some command
I'm running a command with options/parameters based on files.
So I cat the files inside the command.
However, when there's nothing in the file, this is problematic.
mkbootimg --kernel "$...
1
vote
1
answer
145
views
How to define and use global, filenames in a bash script
EDIT: Changed the requirement for dynamically-calculated variable names as I don't strictly need this for my use case, and a solution was provided that works for me.
This is probably impossible to do, ...
0
votes
0
answers
109
views
Pipes and file descriptors within bash scripts
Streaming PI camera video to VLC using the following command from bash prompt works OK:
raspivid -o - -t 0 -w 1280 -h 720 -fps 12 | cvlc stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8081/}' :demux=...
0
votes
1
answer
101
views
How do i fix my bash script output for checking if user's directories exist
grep -E -v '^(halt|sync|shutdown)' /etc/passwd | awk -F: '($7 != "'"$(which
nologin)"'" && $7 != "/bin/false") { print $1 " " $6 }' | while read -r user
...
1
vote
1
answer
2k
views
How to make apache service run continuously from script file from docker?
I am trying to run apache2 service from .sh script from dockerfile. The 'sh' script contains 3 executable commands which is presented as below:
#!/bin/bash
export DISPLAY=:0.0
echo "pvw ...
0
votes
1
answer
767
views
Modify user in openLdap via bash script
Can you please help me put this command into if statement (bash scripting):
$ ldapmodify -D -h
password: [enter password]
dn: cn=vipb,ou=groups,dc=example,dc=com
changetype: modify
add: memberUid
...
1
vote
1
answer
2k
views
PowerShell - Allow non-admin users to disable/enable Tasks
I have a task that triggers every hour, and runs a powershell script. I am supposed to deploy this script along with the task on workstations, where all users are non-admin users, however, the users ...
6
votes
2
answers
5k
views
read in Bash and ZSH
I'm observing differences between zsh and bash when using read on macOS.
With bash this script
echo "characters" | while IFS= read -d '' -n 1 a; do printf %s "$a-"; done
Produces
...
0
votes
1
answer
566
views
BASH - How to combine data from 2 files
I have 2 files with the following data
file1:
datapoint1name##datapoint1name
datapoint1name.PercentUtilization=
datapoint2name##datapoint2name
datapoint2name.PercentUtilization=
datapoint3name##...
0
votes
2
answers
61
views
Using sed only on grep lines in file
I have a file which contains something like this:
192.168.1.1 user=a pass=b name=muzi standalone=true
192.168.1.2 user=a pass=b name=muzi standalone=true
192.168.1.3 user=a pass=b name=muzi standalone=...
0
votes
1
answer
64
views
Reject users script help - bash - freeradius
I have this very small script that allows users to access defined hosts, but I do not know how to reject users to access everything else:
This part of the script works fine:
318 Huntgroup-Name ...
0
votes
1
answer
304
views
What is the easiest way to edit a variable in a bash script from another bash script?
I have a bash script which only contains bash variables. for example:
#!/bin/bash
a="foo"
b="bar"
I also have another script, which should change the values of the variables of ...
0
votes
0
answers
107
views
Why does Bash require closing some statements?
Something I've always wondered but never gotten around to asking. In Bash:
if statements require an ending fi
case statements require an ending esac
do statements require an ending done (which ...
0
votes
3
answers
617
views
How to display weeks, days and hours in script
This is a follow-up question to a previous question regarding a bash script I wrote to help me more accurately keep track of my vices. I'm now trying to modify the script to display all non-zero units:...
4
votes
1
answer
6k
views
How to make getopts parameter optional
I wrote the following bash script as a budgeting tool to more accurately calculate (and moderate) when I last bought a pack of cigarettes.
In addition to -h for printing the output, it takes one other ...
1
vote
1
answer
107
views
Access positional parameters out of order in a for loop
I have a script which makes use of multiple (i.e. positional) arguments from the command line, and within it a for loop that iterates through these arguments:
for i in "$@"; do
...
done
...
0
votes
1
answer
50
views
How to append a carriage return to replacement text in osx bash script
I've tried numerous answers that I searched for here, and for some reason nothing is working
I have a bash script which I'd like to use to process a series of files.
Here's a simplified example
a sql ...
1
vote
2
answers
3k
views
Tar extract a stream of tar files
I've got a binary (lets call it displayFiles) which will get several tar files at once and print the tars to stdout. I then pipe the stdout to tar.
This works fine when the binary only downloads a ...
1
vote
1
answer
10k
views
unexpected EOF while looking for matching `"' ubuntu 20.04
Can someone help me ??? i don't know where is the problem ??
./menu.sh: line 268: unexpected EOF while looking for matching `"'
./menu.sh: line 271: syntax error: unexpected end of file
...
0
votes
1
answer
871
views
Linux | Upload a .tar.gz file to a FTP-Server with encryption enabled and port changed
First forward I gotta say that I'm a scripting noob and just've started to learn Linux.
I need your help with the integrated ftp-client on Linux.
I want to write a script that automaticly packs a ...