8,602 questions
Best practices
0
votes
7
replies
91
views
Does Bash support local variables in POSIX mode?
Does Bash support local variables in POSIX mode?
x=42
echo $x
foo() {
local x=43
echo $x
}
foo
echo $x
$ /bin/bash4 script
42
43
42
$ /bin/bash4 --posix script
?
0
votes
0
answers
89
views
ubuntu curl: (3) URL using bad/illegal format or missing URL
Given the following script:
curl --interface wlan0 --connect-timeout 60 --max-time 1800 -X PUT -T /tmp/compress_log/20250922_utc.tar.gz "https://ota.eu.globe-groups.com/devicelogs/881e3272-4ab4-...
2
votes
4
answers
162
views
Is there a standard way to grab "values" from a "key" in bash?
I'm learning bash from a book and just wanted to see if there is a more efficient way to do this.
The output of cat /proc/acpi/wakeup is multiple lines, but I only care about this one:
GPP0 S4 ...
0
votes
0
answers
49
views
Shell script to execute gradle build and move to .m2
I want to create a shell script to do a gradle build and then deploy to my local .m2. However, my attempt fails. My directory structure is as follows:
my-app # root of project
+ build
+...
5
votes
1
answer
132
views
Create a detached process in linux (shell) to avoid an uncatchable signal
Context : I am making my own cloud save manager for my non steam games, I am in the process of implementing a wrapper that launches games but also loads file from the cloud before opening and when you ...
0
votes
0
answers
40
views
Calling a script from a script, preserving the actual location of the called script
I use a (commercial) software that uses a sh script to start, run_sw. If I run this script from the terminal it works fine. But if I run the script from another script that I have created, my_script ...
0
votes
0
answers
50
views
Jenkins Groovy, how to put variable in oc exec
I would like to get pod name in groovy, and then to use this name to launch script in this namely pod
For example i get pod's name :
def testVar = "Test"
...
2
votes
1
answer
98
views
Unexpected behaviours with inline environment variables expansion
While experimenting with inline environment variables, I noticed that although they are correctly applied to command execution, their expansion sometimes retains the previous value—but not always!
...
0
votes
0
answers
68
views
Can I end a shell script after an instruction
Here's a sample of my script below. Lines 1 to 11 are the information about the script. Lines 12 to 16 are the setup for some of the instructions on my script. Lines 17 to 23 are kind of like a check ...
0
votes
2
answers
116
views
Get telemetry data from Armv7 32bit via a POSIX shell [closed]
I'm working on Quectel EC25 sim-modem converter which has an ARMv7 32-bit CPU. I want to get telemetry data via POSIX commands.
This is the equivalent code in C:
int tempeture(){
FILE *file = ...
0
votes
1
answer
86
views
Shell script with if-else returns command not found error while executing the last line [closed]
I have a shell script to set the CPU frequency to maximum on all cores on Android devices. The contents are:
#!/system/bin/sh
cpucores=`grep -c ^processor/proc/cpuinfo`
cpusint=`echo $((cpucores-1))`
...
1
vote
1
answer
114
views
"Interrupted system call" error on killing child process
I have the following shell script:
#!/usr/bin/env sh
PIPE_PATH="/tmp/mypipe"
test -p "${PIPE_PATH}" || mkfifo "${PIPE_PATH}"
processCommandsFromPipe() {
local pipe=&...
1
vote
1
answer
190
views
Create Signature in Openssl for a JWT for the AS400/iSeries/IBM i
I am struggeling to make a working signature of a certificate which will be used later in a JWT in an RPG-program.
We use this version of openssl: "OpenSSL 3.0.10 1 Aug 2023 (Library: OpenSSL 3.0....
1
vote
0
answers
30
views
How to combine `grep` with `tee` when using a while statement? [duplicate]
This command:
(echo 01 && sleep 1 && echo 02) | grep -E '[1]$' | tee /tmp/output.txt
Outputs 01 to both terminal and /tmp/output.txt
This command:
while true; do date +%S; sleep 1; ...
0
votes
0
answers
27
views
Can't use combination of parenthesis and variables in scripts [duplicate]
I have problems with replacing parenthesis in combination with variables, in ssh.
For instance, replacing (hello123blablabla) with (hello). So, it replaces all together, and parenthesis as well, at ...
0
votes
3
answers
307
views
How to show branch name in prompt only in git repository?
I'm using git bash on Windows 11, and I customized the prompt by modifying the git-prompt.sh file to suit my taste and to display the name of the virtual environment. I changed the prompt to display ...
1
vote
1
answer
56
views
Console output from subshell ONLY on failure
I have complex multi-step 'init' operations which can be ignored when they work. Having the echoed commands and their output at the beginning of every operation swamps the output you care about.
I ...
0
votes
0
answers
124
views
helloworld pipeline hangs on sh command from Jenkins pipeline on a slave
I m on latest Jenkins 2.479.2 with jdk 17.
I was able to start slave node with label Prod_Slave_56 and see no errors.
Agent successfully connected and online
I created new pipeline job runs but hangs ...
3
votes
2
answers
102
views
RegExp testing fails when string is validated in RegExp tools
I have a small regexp that should verify if a commits subject adheres to the ReactJS commit message format. Since the expression works with my test strings the code left me baffled.
This small example ...
0
votes
0
answers
41
views
Shell Script doesn't seem to run using cronjobs in k8
A little new to cronjobs on kubernetes and getting familiar with it.
So I'm trying to migrate my onprem cronjobs to k8 cronjobs. I have created them in the required yaml file with the right mounts. ...
-1
votes
1
answer
156
views
Replicating /etc/profile.d under ~/.profile.d by copying the code from /etc/profile and changing the path [closed]
I'm trying to replicate the functionality of /etc/profile.d by copying the segment of /etc/profile that runs the scripts in profile.d in my ~/.profile, and have it run scripts under ~/.profile.d.
Here'...
5
votes
5
answers
257
views
How can you use awk to replace a pattern with an environment variable?
I am trying to write a simple script that will receive a text via standard input and will output everything as it is except it will replace occurences following this pattern:
{{env MYVAR}}
{{env PATH}...
0
votes
0
answers
51
views
How to set env variable from another one set at build time
I would like to set a variable (say A) from the value of another variable that is only known at build time, for instance HOME:
FROM ubuntu
RUN export A=$HOME/file.txt
Then:
docker build -t mubuntu -&...
1
vote
3
answers
87
views
find -exec sh -c '...' script not honoring variables set in outer script
I am trying to write a shell script to check and delete files/folders
#!/bin/bash
deletepath="path"
donotdelete="$2"
timestamp=$(date +%Y%m%d_%H%M%S)
filename=log_$timestamp.txt
...
-2
votes
1
answer
81
views
how to print curl response json parse using shell script
I have an API or Endpoint below endpoint use GET method:
https://test.cloudnetwork/devops/api/status?over=658xx899xxx68sspo
its response below one
{
"info": testing of cloudnetwork data ...