Menelaos
Menelaos

Reputation: 26005

Shell Script , curl: (6) Couldn't resolve host in

I am writing my first shell script which I want to use to check the output of a server. Unfortunately, I am having trouble running the curl command.

Script:

# first shell script
#
clear;
echo "Knowledge is power";

r=$(( $RANDOM % 10 + 40 ));
echo $r;

test = $(curl \"google.com\");
echo $test

Output:

Knowledge is power
44

curl: (6) Couldn't resolve host '"google.com"'

backuppc@backup-pc:/media/scripts$

Upvotes: 0

Views: 2211

Answers (1)

user142162
user142162

Reputation:

There is no need to escape the double quotes (or, in this case, to even have quotes at all); try it without putting a backslash before them:

test=$(curl "google.com")

Also note that you cannot have spaces before or after the equals sign in variable assignment.

Upvotes: 2

Related Questions