I've Googled a lot but I can't fix this.
For local files I get it to work, but for a networkfile it doesn't.
I want to check if a file on a network exists, but how?
I tried this in my terminal:
[ -f "192.168.1.46:8090/camera.jpg" ] && echo 1 || echo 0
It outputs constantly 0, while I'm sure the file exists, can anyone help me?
EDIT:
To be more clear:
On my Raspberry Pi (with Raspbian), I run FFserver and FFmpeg. It transcode a stream to camera.mjpeg and camera.jpg. The local IP address of my Raspberry Pi itself is 19.168.1.46, so I want to check if file is still there, because sometimes the transcoding process hangs, and the mjpeg is unreadable. I have this shell code now:
#!/bin/bash
url=http://192.168.1.46:80/test.txt
url2=http://192.168.1.46:8090/camera.mjpeg
if curl --output /dev/null --silent --head --fail "$url"; then
echo "URL exists: $url"
else
echo "URL does not exist: $url"
fi
if curl --output /dev/null --silent --head --fail "$url2"; then
echo "URL exists: $url2"
else
echo "URL does not exist: $url2"
fi
This is the output:
URL exists: http://192.168.1.46:80/test.txt
URL does not exist: http://192.168.1.46:8090/camera.mjpeg
The problem is: I know for sure the camera.mjpeg is there, because I can access it via a browser on another PC and view it without problems, but it still says that it doesm't exsists.
wget
orcurl
and check the return code. – Panki Jun 26 '19 at 09:25192.168.1.46:8090
is not a directory specification? ( the:
is allowed in a file-name). – ctrl-alt-delor Jun 26 '19 at 09:47