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?
Girhiny asked 9/11, 2018 at 16:1

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...
Chuddar asked 8/12, 2010 at 0:31

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...
Tankage asked 21/8, 2013 at 10:4

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.
Psychodiagnostics asked 28/1, 2012 at 23:15

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 )"
Gallows asked 23/4, 2015 at 18:54

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 ...
Aida asked 24/3, 2015 at 18:4

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...
Bowman asked 27/10, 2013 at 19:6

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...
Sonority asked 23/9, 2011 at 20:1

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...
Ventriloquism asked 12/6, 2012 at 19:23

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: ...
Danyluk asked 12/2, 2016 at 0:53

3

Solved

What does /bin/sh -c mean? What does -c do?
Shorthorn asked 21/10, 2010 at 7:27

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...
Pallet asked 27/3, 2014 at 19:45

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

Using iTerm2 with zsh and it isn't recognizing my aliases. Sometimes I have to work in an IDE and can't just easily vim something and the stupid people thought it a good idea to name their applicat...
Aaren asked 11/1, 2013 at 21:21

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 ...
Rimskykorsakov asked 22/12, 2013 at 3:21

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?
Abrams asked 16/1, 2011 at 22:34

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...
Irritating asked 25/1, 2017 at 21:8

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...
Monotonous asked 26/2, 2016 at 13:7

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...
Vino asked 8/10, 2012 at 3:0

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...
Invincible asked 2/1, 2023 at 11:50

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...
Interrupter asked 18/5, 2010 at 0:3

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

© 2022 - 2024 — McMap. All rights reserved.