1

I want to open a new terminal when i enter a user-defined command in linux. Means for an example,when i type a command tcpdump in terminal and this will open a new session terminal for the tcpdump.

So in newly opened terminal, for capturing the packet, i have to write only -i eth0 and not tcpdump -i eth0. The new terminal will internally take the command tcpdump.

So will these be possible?

1
  • How do you connect to a Linux session right now? For example, do you use a GUI with xterm, or do you connect using an emulator on Windows?
    – cdarke
    Oct 8, 2012 at 8:33

3 Answers 3

4

I'm going to assume that you want to run the command in a new terminal window on your (Linux) desktop. Most terminal emulators seem to have an option -e for running commands, so you could do something like this:

urxvt -e $SHELL -c 'read -p "Options: " OPTS; tcpdump $OPTS' &

Replace urxvt with aterm, xterm, Konsole or whatever terminal emulator you're using.

If you want the window to remain open after the command finishes, you have to take additional steps (urxvt has an option -hold for this, but other terminal emulators don't).

0

You could get a nice interpreter interface using rlwrap (which you can probably install through your distribution's package manager).

while rlwrap -o -P "tcpdump " -C tcpdump sh; do :; done

This will give you a shell where the command-line line already has "tcpdump " at the beginning. It will also keep a history of the commands you previously ran using the command.

Run exit 1 to quit the shell.

You could use Ansgar Wiechers' method to run the command in a new terminal window.

0

You could try terminator, then splitting windows per command or modify some script I wrote to ssh per server, to split per command would need some work for that to happen but all possible https://github.com/vahidhedayati/termssh

You must log in to answer this question.