curl malformed url

Free Internet troubleshooting agent for Centos, Ubuntu and others. Outages.io automatically finds connectivity issues and gives you hard facts.
Post Reply
sapeters68106
Posts: 5
Joined: Fri Mar 12, 2021 7:35 pm

curl malformed url

Post by sapeters68106 »

I'm having some trouble with the Linux agent installation. Similar problem as viewtopic.php?f=14&t=160&sid=fdcae4a40f ... p=565#p565

I am also able to do a curl if I use the credentials.

[email protected]:/otm# curl -m 20 -s -u (user:pw) --connect-timeout 10 -X POST https://www.foxymon.com/receiver/receiver2.php -F function=receive_binary_location

https://downloads.outages.io/otm/otm_1. ... ckpro:/otm#

[email protected]:/otm#

[email protected]:/otm#

[email protected]:/otm#

[email protected]:/otm#

[email protected]:/otm#

[email protected]:/otm# curl -v -m 20 -s -u <user:password> --connect-timeout 10 -X POST https://www.foxymon.com/receiver/receiver2.php -F function=receive_binary_location

* Trying 184.164.141.219:443...

* Connected to www.foxymon.com (184.164.141.219) port 443 (#0)

* ALPN, offering h2

* ALPN, offering http/1.1

* successfully set certificate verify locations:

* CAfile: /etc/ssl/certs/ca-certificates.crt

* CApath: /etc/ssl/certs

* TLSv1.3 (OUT), TLS handshake, Client hello (1):

* TLSv1.3 (IN), TLS handshake, Server hello (2):

* TLSv1.2 (IN), TLS handshake, Certificate (11):

* TLSv1.2 (IN), TLS handshake, Server key exchange (12):

* TLSv1.2 (IN), TLS handshake, Server finished (14):

* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):

* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):

* TLSv1.2 (OUT), TLS handshake, Finished (20):

* TLSv1.2 (IN), TLS handshake, Finished (20):

* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384

* ALPN, server accepted to use http/1.1

* Server certificate:

* subject: CN=foxymon.com

* start date: Feb 8 16:10:48 2021 GMT

* expire date: May 9 16:10:48 2021 GMT

* subjectAltName: host "www.foxymon.com" matched cert's "www.foxymon.com"

* issuer: C=US; O=Let's Encrypt; CN=R3

* SSL certificate verify ok.

* Server auth using Basic with user 'l1UxzvwhBu'

> POST /receiver/receiver2.php HTTP/1.1

> Host: www.foxymon.com

> Authorization: Basic bDFVeHp2d2hCdTpSYXVoRHhyMWpOc25jWlV5bHpBTU81R2Jwb0ZxM2dUN0JtVzh2WGVW

> User-Agent: curl/7.74.0

> Accept: */*

> Content-Length: 166

> Content-Type: multipart/form-data; boundary=------------------------f0db9c60c65555e9

>

* We are completely uploaded and fine

* Mark bundle as not supporting multiuse

< HTTP/1.1 200 OK

< Date: Sat, 13 Mar 2021 02:44:08 GMT

< Server: Apache

< Expires: Thu, 19 Nov 1981 08:52:00 GMT

< Cache-Control: no-store, no-cache, must-revalidate

< Pragma: no-cache

< Set-Cookie: advanced-backend=uiof82q8o8qra1kom7dkthq5l7; path=/; HttpOnly

< Set-Cookie: _identity-backend=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; Max-Age=0; path=/; HttpOnly

< Set-Cookie: _csrf-backend=bc4b70b337f447cbcee2acd528e9e2c25a2dfac79b5f26214ae166aef4a15464a%3A2%3A%7Bi%3A0%3Bs%3A13%3A%22_csrf-backend%22%3Bi%3A1%3Bs%3A32%3A%22690h-JTA5QuveoK5TrJ2D46V2-45jtxW%22%3B%7D; path=/; HttpOnly

< Transfer-Encoding: chunked

< Content-Type: text/html; charset=UTF-8

<

* Connection #0 to host www.foxymon.com left intact

https://downloads.outages.io/otm/otm_1. ... ckpro:/otm#





Here's my error:

[email protected]:/otm# ./starter_linux_ocp.sh



Make sure to create /etc/agentid with credentials before starting this script

Make sure your starter file points to the same directory that you have it in - Edit the 'start' option above accordingly

You could add this to /etc/rc.local to start it or build a service for it. Please search Google for more.



Receiving binary location

Getting the OTM Package

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

0 162k 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0

Downloading OTM

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

100 162k 100 162k 0 0 382k 0 --:--:-- --:--:-- --:--:-- 383k

OTM downloaded, starting program then exiting this script

./starter_linux_ocp.sh: line 56: /otm/otm_linux: cannot execute binary file: Exec format error

Something didn't work, your agent is not running.

[email protected]:/otm#



agentid has only the 2 lines, no extra spaces or line breaks. My script is in /otm/starter_linux_ocp.sh

[email protected]:/otm# cat starter_linux_ocp.sh

#!/bin/bash



#Version 1.0.3



# Enter the full path where you will be placing the starter_linux_otm.sh script into.

# Our example shows '/agent', change this to what ever your path is.

start="/otm"



command -v curl >/dev/null 2>&1 || { echo >&2 "The curl package is needed but not installed. Please install it and try again. Aborting."; exit 1; }



echo ""

echo "Make sure to create /etc/agentid with credentials before starting this script"

echo "Make sure your starter file points to the same directory that you have it in - Edit the 'start' option above accordingly"

echo "You could add this to /etc/rc.local to start it or build a service for it. Please search Google for more."

echo ""

sleep 5



### Define Global Variables

OTMIN="otm"

IN="$start/updater_linux_ocp.sh"

DATE=`date +%d-%m-%y`

OTM_COMMAND="otm_linux"

USERNAME=`awk 'NR==1' /etc/agentid`

PASSWORD=`awk 'NR==2' /etc/agentid`



### OTM section

# Get rid of any old version

rm -f $start/otm_linux

OTM_HTTP_STATUS=''

OTM_REMOTE_LENGTH=''



### Loop

until [[ ${OTM_HTTP_STATUS} -eq 200 && ! -z ${OTM_REMOTE_LENGTH} ]]

do

sleep 5

##

echo "Receiving binary location"

BINARY_LOCATION=$(curl -m 20 -s -u $USERNAME:$PASSWORD --connect-timeout 10 -X POST https://www.foxymon.com/receiver/receiver2.php -F function=receive_binary_location)

echo "Getting the OTM Package"

curl -I -m 30 --connect-timeout 15 "$BINARY_LOCATION" -o $start/otminfo.log

OTM_HTTP_STATUS=$(cat $start/otminfo.log | awk '/HTTP/ {print $2}')

OTM_REMOTE_LENGTH=$( cat $start/otminfo.log | awk '/Content-Length/ {print $2}' | sed -e 's/[\r\n]//g' )

done



###

if [[ ${OTM_HTTP_STATUS} -eq 200 && ! -z ${OTM_REMOTE_LENGTH} ]]; then

echo "Downloading OTM"

curl -m 30 --connect-timeout 15 "$BINARY_LOCATION" -o $start/otm_linux

sleep 2

OTM_LOCAL_LENGTH=$( ls -l $start/otm_linux | awk '{print $5}' | sed -e 's/[\r\n]//g' )

if [ "${OTM_LOCAL_LENGTH}" == "${OTM_REMOTE_LENGTH}" ]; then

echo "OTM downloaded, starting program then exiting this script"

cd $start

chmod +x $start/otm_linux

# exec $start/otm_linux &

$start/otm_linux &



ps cax | grep otm_linux > /dev/null

if [ $? -eq 0 ]; then

echo ""

echo "Congratulations, your agent is now monitoring your Internet connectivity."

echo "Type 'ps cax | grep otm_linux' to see the process number"

else

echo "Something didn't work, your agent is not running."

fi



fi

fi

[email protected]:/otm#

User avatar
Outages.io_Support
Posts: 243
Joined: Wed Feb 12, 2020 11:09 am

Re: curl malformed url

Post by Outages.io_Support »

Hi,

Yes, for some reason, the agent is not ending up in the same directory specified or something along those lines.
Since your starting directory is /otm, can you ls that directlry and show me what ends up in there after you've run the script.

You should see the following at least.

-rw-r--r-- 1 root root 193 Mar 13 09:02 otminfo.log
-rwxr-xr-x 1 root root 166024 Mar 13 09:02 otm_linux
-rwxr-xr-x. 1 root root 2335 Sep 12 10:27 starter_linux_otm.sh

You mentioned trying the download directly using the credentials and that worked. That makes me wonder if the directory where the script is running is not writable or something along those lines.
I'm with the Outages.io support team. Please post your question and I'll try to answer

Are the issues in your local network, with your Internet provider or beyond?
Save countless hours by letting Outages.io help you find Internet connection problems.

sapeters68106
Posts: 5
Joined: Fri Mar 12, 2021 7:35 pm

Re: curl malformed url

Post by sapeters68106 »

Here are the contents of /otm

[email protected]:/otm$ ls
otminfo.log otm_linux starter_linux_ocp1.sh starter_linux_ocp.sh

The other .sh is one I edited using the actual credentials for the curl instead of the variables for user/pw, but got same results. (As mentioned before, if I execute curl from the prompt, it is successful.

[email protected]:/otm# ./starter_linux_ocp1.sh

Make sure to create /etc/agentid with credentials before starting this script
Make sure your starter file points to the same directory that you have it in - Edit the 'start' option above accordingly
You could add this to /etc/rc.local to start it or build a service for it. Please search Google for more.

Receiving binary location
Getting the OTM Package
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 162k 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
Downloading OTM
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 162k 100 162k 0 0 415k 0 --:--:-- --:--:-- --:--:-- 414k
OTM downloaded, starting program then exiting this script
./starter_linux_ocp1.sh: line 56: /otm/otm_linux: cannot execute binary file: Exec format error
Something didn't work, your agent is not running.
[email protected]:/otm#

sapeters68106
Posts: 5
Joined: Fri Mar 12, 2021 7:35 pm

Re: curl malformed url

Post by sapeters68106 »

Here, this is a better view.

[email protected]:/otm# ls -la
total 184
drwxr-xr-x 2 root root 4096 Mar 13 15:11 .
drwxr-xr-x 19 root root 4096 Mar 12 17:42 ..
-rw-r--r-- 1 root root 193 Mar 13 15:11 otminfo.log
-rwxr-xr-x 1 root root 166024 Mar 13 15:11 otm_linux
-rwxr-xr-x 1 root root 2366 Mar 12 18:25 starter_linux_ocp1.sh
-rwxr-xr-x 1 root root 2332 Mar 12 17:48 starter_linux_ocp.sh

sapeters68106
Posts: 5
Joined: Fri Mar 12, 2021 7:35 pm

Re: curl malformed url

Post by sapeters68106 »

Also, I'm running this on a Pine64 RockPro64, 64-bit ARM platform. And I'm trying to run your Linux Debian 7 script.

[email protected]:~$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux bullseye/sid"
NAME="Debian GNU/Linux"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
[email protected]:~$ uname -r
5.10.0-4-arm64
[email protected]:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux bullseye/sid
Release: testing
Codename: bullseye
[email protected]:~$ lsb_release -d
Description: Debian GNU/Linux bullseye/sid
[email protected]:~$ hostnamectl
Static hostname: rockpro
Icon name: computer
Machine ID: b4c2b6335c05427290bd2213cb9dd2ac
Boot ID: 1f307ff6a0b344efa95baf617efad53d
Operating System: Debian GNU/Linux bullseye/sid
Kernel: Linux 5.10.0-4-arm64
Architecture: arm64

sapeters68106
Posts: 5
Joined: Fri Mar 12, 2021 7:35 pm

Re: curl malformed url

Post by sapeters68106 »

OK, I got it working using the proper agent. :)

Thanks for the support!

User avatar
Outages.io_Support
Posts: 243
Joined: Wed Feb 12, 2020 11:09 am

Re: curl malformed url

Post by Outages.io_Support »

LOL, I was just about to say...

Glad you got it running :).
I'm with the Outages.io support team. Please post your question and I'll try to answer

Are the issues in your local network, with your Internet provider or beyond?
Save countless hours by letting Outages.io help you find Internet connection problems.

Post Reply