0

From a bash script, I want to open a LXTerminal window and execute several commands, e.g.:

lxterminal -e "echo 'Hello' && sleep 5"

It doesn't even read the first command (as I tried to invert order) and wont work either with a simple command1 ; command2 chain. Obviously, it works with a single command.

Any ideas? Thank you in advance.

1

This is a documented bug with lxterminal. Do you have an alternative terminal program available? xterm, gnome-terminal etc? lxterm (different from lxterminal) has full support for what you are trying to do which is discussed in that bug report. I don't have easy access to that package from my environment and didn't look at it.

A fully functional workaround would be to generate a shell script that contains your command sequence, and have the command passed to lxterminal simply be that script.

For example, in the section of your script that makes this lxterminal call, do something like this:

tmpScript=$(mktemp -u) || { echo "tmp file generation error!"; exit 1; }
echo '#!/bin/bash' > $tmpScript
echo "echo 'Hello' && sleep 5" >> $tmpScript
chmod +x $tmpScript
lxterminal -e "$tmpScript"

That works, at least in my environment (fed 24; x86_64; lxterminal version 0.2.0, kernel 4.6.5).

Unless lxterminal is your only option, it isn't the right tool for this job. Considering the age of that bug, it likely won't ever be. xterm is typically the most popular option for this sort of thing for portability and ease of use, although I'm partial to konsole.

  • Oh OK, thanks. Guess I'll install xterm and pray for LXTerminal to be fixed. Cheers. – Juan Aug 15 '16 at 16:43
0

You could use any other terminal where this is working. For example in xterm this is working:

xterm -e "echo 'Hello' && sleep 5"

As xterm is a default terminal emulator for X, this should be a solution for you too.

0

Solution is to make it with --command modifier like that; lxterminal --command cd ~/some/catalog && echo 'Hello'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.