Why `uname -a` invoke exit1 for sslocal? - bash

The shadowsocks client was running in my pc.
uname -a
Linux MiWiFi 3.16.0-4-amd64 #1 SMP Debian 3.16.43-2+deb8u2 (2017-06-26) x86_64 GNU/Linux
[1]+ Exit 1 sudo sh -c '/usr/bin/nohup /usr/local/bin/sslocal -c /etc/shadowsocks_racks.json > /var/log/ss.log 2>&1'
Why command uname -a invoke Exit1 for sslocal here?
What does Exit 1 sudo sh -c '/usr/bin/nohup /usr/local/bin/sslocal -c /etc/shadowsocks_racks.json > /var/log/ss.log 2>&1'
mean ?

Why command uname -a invoke Exit1 for sslocal here?
You've completely misinterpreted the output. Before uname ran, a background command running as job 1 exited with a status code of 1. The shell couldn't tell you until a command was run, and now you have been told.

Related

Empty ssh invitation (no "user#host:~$") when run command after connect (sh script, sshpass)

Client OS: MacOS 12.1, Server OS: Linux Debian 9 (any server)
case 1:
#!/bin/bash
sshpass -p mypass ssh user#host.ru -o StrictHostKeyChecking=no
works fine:
case 2:
#!/bin/bash
sshpass -p mypass ssh user#host.ru -o StrictHostKeyChecking=no "cd /var/www ; git status ; /bin/bash"
Output of "git status" works fine, but
no "user#host:~$" message in output (input is active).
I tried:
/bin/bash
bash -l
(in server "echo $SHELL" shows /bin/bash)
How to fix it?
Use ssh -t and && inside commands list
#!/bin/bash
sshpass -p mypass ssh -t user#host.ru -o StrictHostKeyChecking=no "cd /var/www && git status && /bin/bash"

"bash -c" vs. "dash -c"

dash -c behaves differently from bash -c:
docker run -it ubuntu /bin/dash -c ps
PID TTY TIME CMD
1 ? 00:00:00 sh
7 ? 00:00:00 ps
docker run -it ubuntu /bin/bash -c ps
PID TTY TIME CMD
1 ? 00:00:00 ps
Is there an explanation for this difference?
bash has an optimisation where the very last command in a script implicitly gets executed with exec. dash recently gained this optimisation as well, but not yet in the version you're using. You'll see the same behaviour with bash -c 'exec ps' and dash -c 'exec ps'.

shell script executing network configuration hangs over tmux

I am executing a shell script which is doing some network configuration.
when i execute this script using tmux it hangs.
===
Here how I am executing tmux in my bash
ARGS=$*
tmux new-session -d -s ISA_INSTALL "./installaccess $ARGS"
tmux attach
=====
Command which hangs is
0 16:54:33 cmd /usr/bin/ssh -x -o NumberOfPasswordPrompts=0 -o StrictHostKeyChecking=no -o GSSAPIAuthentication=no -o ControlMaster=auto -o ControlPath=/var/tmp/installaccess-201607251641FNK/_ssh_%h -o ControlPersist=yes 10.209.192.171 "LC_ALL=C; LANG=C; export LC_ALL LANG; /sbin/ip addr flush eth2 >/dev/null 2>&1; /sbin/ifconfig eth2 down >/dev/null 2>&1" 2>/dev/null
0 17:08:18 CPI WARNING V-9-20-1051 Interrupt Received--installaccess terminated

How can I get dtruss on Mac OS X to successfully trace child processes?

The dtruss man page says:
-f follow children as they are forked
which sounds like exactly what I want. However, observe the following behavior:
WhiteAndNerdy% uname -a
Darwin WhiteAndNerdy.local 13.4.0 Darwin Kernel Version 13.4.0: Wed Dec 17 19:05:52 PST 2014; root:xnu-2422.115.10~1/RELEASE_X86_64 x86_64
WhiteAndNerdy% sudo dtruss -f -t writev /bin/echo hello world
hello world
PID/THRD SYSCALL(args) = return
37273/0x90e264: writev(0x1, 0x7F8832D00000, 0x4) = 12 0
WhiteAndNerdy% sudo dtruss -f -t writev sh -c '/bin/echo hello world'
PID/THRD SYSCALL(args) = return
WhiteAndNerdy% sudo dtruss -f -t writev bash -c '/bin/echo hello world'
PID/THRD SYSCALL(args) = return
WhiteAndNerdy% sudo dtruss -f -t writev zsh -c '/bin/echo hello world'
PID/THRD SYSCALL(args) = return
37295/0x90e39b: fork() = 0 0
WhiteAndNerdy% sudo dtruss -f -t writev env /bin/echo hello world
PID/THRD SYSCALL(args) = return
WhiteAndNerdy%
Note that except for the first case, "hello world" is not printed. (And it isn't just a matter of the output not being seen; if I run a process that takes a long time, it doesn't take any time under the sh -c and similar cases. In all the experiments I've done, it appears that execution simply stops at the first exec.)
So, I'm puzzled what dtruss -f actually does. How can I get it to behave like strace -f on Linux, which does what I want?
Motivation: I'm doing some Haskell development on OS X, and would like to trace what's happening during a run of cabal (Haskell's build system). Running dtruss -f on cabal returns without doing anything at all, because in the OS X version of the Haskell Platform, /usr/bin/cabal is a shell script which execs /Library/Haskell/bin/cabal.real. Of course, I can get around that problem by just running /Library/Haskell/bin/cabal.real directly, but that still doesn't buy me much, since cabal.real is just going to turn around and exec a bunch of other stuff. (Think make if you're not familiar with Haskell.)

Linux: su error when run as root

why following command gives an error exit code, when run as root (tested under SLES11, RedHat 5.1):
srl-suse11-test:/tmp # su - user1 -c 'echo hallo'
srl-suse11-test:/tmp # echo $?
1
Thank in advance

Resources