2

I'm trying to open a new Konsole and run multiple commands on it basically from my opened terminal shell I need to:

  1. Open a new terminal shell
  2. Set environment located in a specific folder
  3. Run gedit for instance
  4. Run another application (could be an alias)

Right now I tried the option:

konsole --noclose -e 'source /$MYTOOLS/env.csh | gedit | aliasApp'

but it gives me the following error:

Warning: could not find 'source /$MYTOOLS/env.csh | gedit | aliasApp' , starting '/bin/tcsh' instead. Please check your profile settings

3

The -e konsole command-line option specifies a program to run in the newly-created terminal emulation; normally, it would be a shell (such as /bin/bash or /bin/tcsh) but it could be any console program. It can be any executable; it will be run with its stdin, stdout and stderr redirected to the emulated terminal created by konsole.

What it cannot be is a line which needs to be interpreted by the shell, since that is not the path to an executable.

However, you can pass arguments to the executable. You just add them to the end of the konsole invocation. And shells -- including tcsh, which you seem to be using, and bash -- allow you to specify a single command to execute by using the -c command-line option. So you could do this:

konsole -e /bin/tcsh -c 'source /$MYTOOLS/env.csh && gedit && aliasApp'

(It's not clear to me why you would want to start up a terminal emulator in order to run gedit, which is GUI-based. But perhaps it was just an example.)

Be aware that the shell will terminate once the provided command-line string is completed, and konsole will terminate when the specified executable terminates. So that will not end up providing you with a shell after executing those commands.

If you want to create a shell with a specific set of initialization procedures, you need to use a shell-specific mechanism to run the initialization script. For bash, for example, you can use the --rcfile command-line option to specify a custom start-up script; unfortunately, this option is not understood by tcsh, so you would need to do something else (like pass the filename in an environment variable and have your normal startup script source the file if the environment variable is set).

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.