Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

/* Halley */ (Halley's comment.)


devel / comp.lang.tcl / Catching a SSH error that seems non-existent

SubjectAuthor
* Catching a SSH error that seems non-existentLuis Mendes
`- Catching a SSH error that seems non-existentRich

1
Catching a SSH error that seems non-existent

<6532a281$0$705$14726298@news.sunsite.dk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12275&group=comp.lang.tcl#12275

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail
From: luisXXXl...@gmail.com (Luis Mendes)
Subject: Catching a SSH error that seems non-existent
Newsgroups: comp.lang.tcl
MIME-Version: 1.0
User-Agent: Pan/0.154 (Izium; 517acf4)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Date: 20 Oct 2023 15:53:37 GMT
Lines: 44
Message-ID: <6532a281$0$705$14726298@news.sunsite.dk>
Organization: SunSITE.dk - Supporting Open source
NNTP-Posting-Host: bd11a38d.news.sunsite.dk
X-Trace: 1697817217 news.sunsite.dk 705 luislupe@gmail.com/176.79.151.101:59881
X-Complaints-To: staff@sunsite.dk
 by: Luis Mendes - Fri, 20 Oct 2023 15:53 UTC

Hi,

I've built a script to get some json array from another server.
It should ssh as my user and do a "sudo su - -c 'some command'" in one
swallow.

When I run the entire command from the command line, no error is returned.
echo $? returns 0.

If I ssh to the machine first and then run the "sudo su - -c 'some
command'", there's no error, too.
echo $? returns 0.

If I ssh to the machine, sudo su -, and only then execute the 'some
command', no error is returned.
echo $? returns 0.

This is the section of the Tcl script where the call is made:

set json ""
if {[catch {exec ssh -T $master_server "sudo su - -c '$cmd'"} json ropts]}
{ puts stderr [dict get $ropts -errorcode]" ;# NONE
puts stderr [dict get $ropts -errorinfo]" ;# returns the json
array fine and the ssh banner text after it
puts stderr [dict get $ropts -errorline]" ;# 32
}

Although
1. This is working fine, as it returns the json array;
2. I print to the screen the whole command, copy and paste it to another
terminal and works fine, too;

Why does the exec returns an error that is caught?
Why is the error NONE?
What is that 32nd line? If I count it from the beginning of the [dict get
$ropts -errorinfo] output, it's just a json 'paramter: value' pair.

I'm not understanding what is wrong.

Luís

Re: Catching a SSH error that seems non-existent

<ugu8pl$16ad3$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12277&group=comp.lang.tcl#12277

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ric...@example.invalid (Rich)
Newsgroups: comp.lang.tcl
Subject: Re: Catching a SSH error that seems non-existent
Date: Fri, 20 Oct 2023 16:10:29 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <ugu8pl$16ad3$2@dont-email.me>
References: <6532a281$0$705$14726298@news.sunsite.dk>
Injection-Date: Fri, 20 Oct 2023 16:10:29 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="ce2c82e670e7ee9495f2479c8720d6bd";
logging-data="1255843"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uMAx28Um1hWXYc8eM6fIB"
User-Agent: tin/2.6.1-20211226 ("Convalmore") (Linux/5.15.117 (x86_64))
Cancel-Lock: sha1:nbVLBP8Lg2CcnPbdIfxfGY6ZVAE=
 by: Rich - Fri, 20 Oct 2023 16:10 UTC

Luis Mendes <luisXXXlupeXXX@gmail.com> wrote:
> set json ""
> if {[catch {exec ssh -T $master_server "sudo su - -c '$cmd'"} json ropts]}
>
> Why does the exec returns an error that is caught?
>
> I'm not understanding what is wrong.

If you read the documentation for [exec] you will see that exec will
also throw an error if the exec'ed process writes anything to the stderr
stream.

Is it possible that one of sudo, su, or 'cmd' writes something to
stderr?

Also, "sudo su" is extraneous, you really only need one or the other,
not both together, to become root (provided 'sudo' is setup to let your
regular user 'sudo' to root).

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor