sh Questions
6
Solved
I try to do the script:
#!/bin/bash
IP='192.168.1.1'
fping -c1 -t300 $IP 2>/dev/null 1>/dev/null
if [ "$?" = 0 ]
then
echo "Host found"
else
echo "Host not found"
fi
and i turn it:
pi@r...
Francyne asked 4/5, 2015 at 18:44
10
Solved
I am running a command
./startup.sh nginx:start
and I am getting this error message
zsh: permission denied: ./startup.sh
why could this be happening?
10
Solved
PHP has mysql_real_escape_string() to correctly escape any characters that might cause problems. What is the best way to mimic this functionality for BASH?
Is there anyway to do prepared mysql st...
7
Can anyone suggest how to comment particular lines in the shell script other than #?
Suppose I want to comment five lines. Instead of adding # to each line, is there any other way to comment the f...
14
Solved
I need the ability to run a PHP script 20 times a day at completely random times. I also want it to run only between 9am - 11pm.
I'm familiar with creating cron jobs in linux.
4
Solved
I have the following code in my bash script. Now I wanna use it in POSIX sh. How can I convert it?
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null && pwd )"
4
Solved
Is it possible to export a function in Bourne shell (sh)?
The answers in this question indicate how to do so for bash, ksh and zsh, but none say whether sh supports it.
If sh definitely does not ...
11
Solved
I'm studying the content of this preinst file that the script executes before that package is unpacked from its Debian archive (.deb) file.
The script has the following code:
#!/bin/bash
set -e
# A...
13
I am trying to create an alias that uses both multiple Git commands and positional parameters. There are Stackoverflow pages for each, and it would appear painfully obvious to do both, but I am hav...
6
Solved
I am trying to use xargs to call a more complex function in parallel.
#!/bin/bash
echo_var(){
echo $1
return 0
}
seq -f "n%04g" 1 100 |xargs -n 1 -P 10 -i echo_var {}
exit 0
This returns the...
7
I've written a sh script in one of my ubuntu VMs which works fine, but when I try to run it in my other VMs, it does not work. Both VMs should be the same. With bash --version both VMs reply with: ...
3
Solved
What does /bin/sh -c mean? What does -c do?
7
Solved
I want to print code into a file using cat <<EOF >>:
cat <<EOF >> brightup.sh
!/bin/bash
curr=`cat /sys/class/backlight/intel_backlight/actual_brightness`
if [ $curr -lt 44...
19
Solved
I have defined the same path in the $PATH variable 6 times.
I wasn't logging out to check whether it worked.
How can I remove the duplicates?
The $PATH variable looks like this:
echo $PATH
/u...
Nuclear asked 25/7, 2012 at 13:29
7
Solved
This question about using cURL with a username and password has suboptimal answers for me:
curl -u "user:pw" https://example.com puts the pw in the process list
curl "https://user:[email pro...
Caboodle asked 19/11, 2015 at 3:37
16
Solved
7
I am trying to get the pid of a currently executing subshell - but $$ is only returning the parent pid:
#!/usr/bin/sh
x() {
echo "I am a subshell x echo 1 and my pid is $$"
}
y() {
echo "I am ...
6
Solved
I have this script called test.sh:
#!/bin/bash
STR = "Hello World"
echo $STR
when I run sh test.sh I get this:
test.sh: line 2: STR: command not found
What am I doing wrong? I look at extreme...
Swamp asked 15/2, 2010 at 18:32
7
Solved
To store the output of a command as a variable in sh/ksh/bash, you can do either
var=$(command)
or
var=`command`
What's the difference if any between the two methods?
6
Here's the content of my crontab file:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO="[email protected]"
*/5 * * * * sh /robot/1/master.sh >/dev/null 2>&1
*/5 * * * * s...
6
Solved
In pure /bin/sh how can I distinguish between an empty variable, an unset variable and a not existing (not defined) variable.
Here are the case:
# Case 1: not existing
echo "${foo}"
# Case 2: un...
8
Solved
I want to define a shell function
#!/bin/sh
test ()
{
do_some_complicated_tests $1 $2;
if something; then
build_thisway $1 $2;
else
build_otherway $1 $2;
fi
}
in such a way that I can use...
2
Solved
I am trying to run shell script with a curl command as below with --data-raw as body.
curl --location --request POST '<URL>' \
--header 'Content-Type: application/json' \
--data-raw '{
&quo...
17
Solved
In a shell script, how do I echo all shell commands called and expand any variable names?
For example, given the following line:
ls $DIRNAME
I would like the script to run the command and displ...
31
Solved
I am trying to run a cronjob inside a docker container that invokes a shell script.
How can I do this?
Dubois asked 26/5, 2016 at 10:32
1 Next >
© 2022 - 2024 — McMap. All rights reserved.