0

ok, here it is. I'm trying to do a bash script to update the binary of an application using lynx. but, the problem is, i cant get it to work. i tried to remove the null part of my script and its working. but, i want the null part to make sure that the lynx is installed. i'm using debian10 as of now. The error is: please install lynx package ok, here is my script. note: the lynx is install as of now.

#!/bin/bash
if which $appname > /dev/null 2>/dev/null;then
sleep .01
else
$0 binupdate
$0 $@
fi
if [ -z $1 ];then
echo specify command. Valid commands are: disable, enable, new, remove, restart, start, stop
exit 1
fi
case "$1" in
binupdate)
if which lynx > /dev/null 2>/dev/null;then
echo please install lynx package
exit 2
fi
if id -u|grep -qw 0;then
#some process#
cd /usr/bin
curl $url|tar --strip-components=2 -xz $dirname/appname
else
echo please run binary updates as root by running: sudo $0 binupdate
fi
;;
  • 1
    First step for debugging bash scripts: Run it through https://shellcheck.net and fix the issues it points out. – Shawn Sep 12 '21 at 09:36
  • And why are you looking for `lynx` when you appear to be using `curl` instead to download a file? – Shawn Sep 12 '21 at 09:38
  • If your problem is not caused by serious quoting issues, they are probably at least obscuring any further debugging. See [When to wrap quotes around a shell variable?](https://stackoverflow.com/questions/10067266/when-to-wrap-quotes-around-a-shell-variable) – tripleee Sep 12 '21 at 10:06

0 Answers0