[ Date Index ]
[ Thread Index ]
[ <= Previous by date /
thread ]
[ Next by date /
thread => ]
Re: [LUG] standard error handling
- To: list@xxxxxxxxxxxx
- Subject: Re: [LUG] standard error handling
- From: Michael Dorrington <michael.dorrington@xxxxxxxxxxxxxx>
- Date: Sun, 1 Sep 2019 17:34:50 +0100
- Autocrypt: addr=michael.dorrington@xxxxxxxxxxxxxx; prefer-encrypt=mutual; keydata= mQINBEqZj2IBEADPLnnffqChkft2CBDh3OneFP1i9ndEZ3QDSX/oDVZusDIKIBobEmpCNUjZ D8m2XgCfaD76DwUr9SOPUunGC7WtZxGs2HrVTO/Q6gH4FAVROP79U1OrwkD/4HdSXIy6DmGr nHWTuJIeyjSa8vVwmU2Z0yydB4wy/+L0yWCnOvWVY7roXqmDqpivKgvxNfUeLDO8lazg9/2v vLiq+47k+oue2aUieiSbXRy6v8SMkFW5692fsEhEeoDELy9Ytah3SSGdQFDjAW4g538V6HMx WI5gCB2UQlpF/FE0w5cyrBmDAVAWTvmbhNAlRjydlDEKQymmGbbRdjQqMlQK+wC0POLAJXZY 756dTqb9JL4Dbs+Z2BBwBq0R58V339nHVl9LNP6a/W7yazogmJX1gxE6nNYWvjHreuUY+666 4ceyVcfiQoiwtBpbb2HBWgy09xpiUBEvKm0tUzUBNkows2NHgVfVF/Cx8R5Hxyw74Myv9zpI UkGYfYjTXqkeHkurYSSs/qzMDr+bHCsfpunJv4v4eUi91s7ytEqUecvJg24JORt500gDAYpW HIWx1xRK3YtXD7S2LcoYQMq8knSHOtZ7f3j0plRLw6c46Am2Dqi66Y9h19Yw100WkaVWTlMM jbykHH4mPqT9CIzuRXelJkEW3k4JWR9/PKOlHzAlVcUVCHUFkwARAQABtDZNaWNoYWVsIERv cnJpbmd0b24gPG1pY2hhZWwuZG9ycmluZ3RvbkBtZW1iZXIuZnNmLm9yZz6JAjcEEwEIACEF AlLIOqQCGwMFCwkIBwMFFQoJCAsFFgIDAQACHgECF4AACgkQ13JsPqr44+9jpg//WWxVKHk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; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dclug.org.uk; s=1554804362; h=Sender:Content-Type:Reply-To:List-Subscribe: List-Help:List-Post:List-Unsubscribe:List-Id:Subject:In-Reply-To:MIME-Version :Date:Message-ID:From:References:To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner:List-Archive; bh=mv/JEGWabvcaA5s8z+ka1bxHy6vp+o8CfDukBHVCvVM=; b=drAs/pPtvO1ox2QID9+3zi6IGm VGSKv91vB7i4IKcXlSUz3wkiuJxGlxT6haPOBKn7H1zKeGtFhxxqYlEnwbIRThMvOq4WPOznj8uq1 a9yh/csrEnmwryPhMmn6WdmoFrPSpiYrD/K6eNEe0LkX2LJwO+UGW35jbz8UkoYdUvk8=;
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:references:from:openpgp:autocrypt:subject:message-id:date :user-agent:mime-version:in-reply-to; bh=iux0fshrLU1y7BpLF55cjfzc1xEObCgtNSsOkrTNUUA=; b=jj8iyYBec22Uv/83dwmC5jX9ZQLH15XabZEEKEdun75LuGMI/uvbXpjTDF5wkDqbrY KGB+1Np2wwSDlCWWY8NH84lyiecwinVuxiJXBE8hh7G4qKJZqMClhNSSzrcChkE0ugwC cuavABES7qwtAjSq9ydmpC7QAKpfUGsLDf1jUlJju4lyL/DE8T2TrJBuEP7MaQK6EeH9 k1L//tHn9e//mpguH+DMmOFgoUkxASad5UdAlt4TVqpaEla8/fScp9s/OjFvYyat4Mlg PyVdbhqzxmBx/wWyAdDaYbtLqnIF2yNXBVFFqefVfYwYQiawOc0Dk1ujp/yire2FpSuE zO4A==
- Openpgp: preference=signencrypt
On 01/09/2019 16:44, Paul Sutton wrote:
> Hi
>
>
> I am trying to write a shell script in whiptail ( this is a graphical
> toolkit for bash)
>
> whiptail --title "Check list example" --checklist \
> "Choose user's permissions" 20 40 4 \
> "Hello" "Print Hello" OFF \
> "Goodbye" "Print Goodbye" OFF \
> "CYA" "Print cya" OFF \
>
> CHOICEs=$?
$? is the exit status code, a number from 0 to 255. See `man bash`
section "EXIT STATUS" and "Special Parameters". Use that to tell if the
command ran OK or not BUT it won't have the choices.
> echo $CHOICEs
>
> if $CHOICEs = "Hello" ; then
> echo "you selected hello"
> elif $CHOICEs = "Goodbye" ; then
> echo "You Said Good bye"
> elif i$CHOICES = "CYA" ; then
> echo "You said cya"
> fi
What you need to do is a little redirection dance to swap over stdout
and stderr on the whiptail command. Then assign a variable to the
(standard) output of whiptail. So:
CHOICEs=$(whiptail .... 3>&2 2>&1 1>&3)
Then "CHOICEs" will contain space separate list of tags in double
quotes. You'll have parse that; bash does regex! :)
Another option is output stderr to file and then read that in later.
M.
> This produces a small menu with check boxes (so the first part works),
> I can select what I want and press Ok.
>
> I am not really sure how do handle the output and the 2nd part of this
> script doesn't work as expected. But I don't fully understand stderr
> which is the how whiptail outputs to the console / terminal.
>
> Using the information at (
> https://en.wikibooks.org/wiki/Bash_Shell_Scripting/Whiptail#Check_list i
>
> This just tells me how to handle the graphical part of this. Not how
> to handle what is produced.
>
> Clearly the example above is meant to echo to the screen something
> relating to the options selected, however as echo can be replaced with
> other commands I am just keen to get this working on a very basic level
> before I try and do something a little more complex.
>
> Can anyone help please.
>
> thanks
>
> Paul
>
--
FSF member #9429
http://www.fsf.org/register_form?referrer=9429
http://www.fsf.org/about
"The Free Software Foundation (FSF) is a nonprofit with a worldwide
mission to promote computer user freedom and to defend the rights of all
free software users."
Attachment:
signature.asc
Description: OpenPGP digital signature
--
The Mailing List for the Devon & Cornwall LUG
https://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq