Command option substitution?

Hi folks,

I totally dislike asking questions in forums but this one eats up to much of my time I need to spend on other topics.

I have a shell-script in which I call a terminal.
I want to invoke bash inside the terminal and print a message inside bash with aid of a here document.

See yourself.

( DISPLAY=:0 xfce4-terminal --command /bin/bash & )

works just fine and opens up a terminal with bash inside. But if I try to pass a command to bash itself the script fails.

( DISPLAY=:0 xfce4-terminal --command /bin/bash <(cat <<EOF some stupid text EOF) & )

I don't get it working.
A much nicer approach would be if I can pass a function (declared and defined) to bash?

I suppose the problem is, that bash is running in the context of the subshell of the terminal but my imagination and knowledge ends there.

I am almost sure that piping the result of a function in such a nested scenario is impossible.

Greets

bluntroller

Here documents require that EOF is at the start of the on a separate line and that is the only text on the line, so using you code as an example, you would need something like this

    cat <<EOF
echo some stupid text 
EOF

Alternatively you could use a here-string

Passing a function is possible with bash through an export of the function, but can this easily become a security risk, so imho is best avoided.

For passing text to a sub process you can use a named pipe if you just want it to display the message,
or use bash 4's coproc functionality for a two-way pipe.

Hey,

thanks for the 'input'.
Appreciate.
Of course, you are right about 'the thing' with EOF. My fault.

Anyway.... the terminal still pops up without the message I'd like to display.

The command in the argument of the invocation of bash simply doesn't get validated no matter which approach I take.

Try something like this:

( DISPLAY=:0 xfce4-terminal --command /bin/bash -c "echo hello; sleep 10" & )

nope

:slight_smile:

---------- Post updated at 06:43 AM ---------- Previous update was at 06:25 AM ----------

I'd really like to avoid it but I guess I am simply going to put the message in a file. I hate it if things don't work out like I want it. .-)

If someone knows a one-line solution I'd really like to know it!
But it seems difficult as there are several subshells involved and bash supposedly has some security mechanisms in conflict with the task to solve.

Thanks for your considerations.

Am out

I'm sorry things aren't working out the way you want. But I'm confused as to what exactly is going wrong. You say that:

( DISPLAY=:0 xfce4-terminal --command /bin/bash & )

works. You said that some unspecified command fails, but don't show us what command you used and you don't tell us how it failed. Without clearly seeing what you're trying to do and knowing how what you have tried fails, it is really hard to suggest alternatives that might work for you.

Please show us what command you are trying to get bash to run in the terminal window you are opening, tell us what output is being produced, and tell us what output you were hoping to produce.

Take any binary in /bin.

I thought it was self-explaining and didn't need any further explanation what I am trying to accomplish with this quite easy to understand fragment of a script.

Well, I just tried to present a solution but the ******* code-tags don't like my strict browser settings I guess.

However, the man page of the terminals might help... helps..

However, I am a bit ****** off actually because of the whole java-stuff going on this server stealing my time. I asked for the delete of my account.

I am afraid I am no more interested in the post.
Sorry.

Greets

George

Then it's closed. And keep your profanity to yourself, please.