You are not logged in.

#1 2014-06-18 07:27:33

darknesspider
Member
Registered: 2014-06-18
Posts: 3

konsole --new-tab and sudo

sudo ifconfig eth0|grep "inet addr"|awk -F ' ' '{print $2}'|awk -F ':' '{print $2}'   ---->> this command ok
but
konsole --new-tab --hold -e /bin/sh -c "echo "pwd" | sudo -S ifconfig eth0|grep "inet addr"|awk -F ' ' '{print $2}'|awk -F ':' '{print $2}'"
not run...

Offline

#2 2014-06-18 09:11:29

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,304

Re: konsole --new-tab and sudo

You need to escape all the double quotes inside the command string of the -c option:
-e /bin/sh -c "echo \"pwd\" ...

and the $ signs also: \$

Last edited by berbae (2014-06-18 09:36:18)

Offline

#3 2014-06-18 09:19:59

darknesspider
Member
Registered: 2014-06-18
Posts: 3

Re: konsole --new-tab and sudo

how ? for example ? i try but not runing

Offline

#4 2014-06-18 09:25:33

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,304

Re: konsole --new-tab and sudo

Give the exact command you run and the error message please.

In fact you need to escape the $ signs also.

Last edited by berbae (2014-06-18 09:37:09)

Offline

#5 2014-06-18 10:01:49

darknesspider
Member
Registered: 2014-06-18
Posts: 3

Re: konsole --new-tab and sudo

sudo ifconfig eth0|grep "inet addr"|awk -F ' ' '{print $2}'|awk -F ':' '{print $2}'  --->>> result 10.6.5.25 my local ip OK...

but i need result on new console

konsole --new-tab --hold -e /bin/sh -c "echo "pwd" | sudo -S ifconfig eth0|grep "inet addr"|awk -F ' ' '{print $2}'|awk -F ':' '{print $2}'"

not run...

Last edited by darknesspider (2014-06-18 10:02:29)

Offline

#6 2014-06-18 14:39:29

berbae
Member
From: France
Registered: 2007-02-12
Posts: 1,304

Re: konsole --new-tab and sudo

You just repeat your first post without any changes in the konsole launch command: why?
I told you that you need to escape the double quotes and the dollar signs inside the command string of the -c option.
That will lead you to:

konsole --new-tab --hold -e /bin/sh -c "echo \"pwd\" | sudo -S ifconfig eth0|grep \"inet addr\"|awk -F ' ' '{print \$2}'|awk -F ':' '{print \$2}'"

Your command could be simplified to just two pipes (maybe even one), I think; but with your writing you need escaping as I showed you.

Thinking about it, why do you need to run a konsole new tab just to show something? You have notification tools for that, like notify-send or others.

Last edited by berbae (2014-06-18 15:14:48)

Offline

Board footer

Powered by FluxBB