Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Oct 8 '12 at 11:33

This question came from our site for professional and enthusiast programmers.

    
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 '12 at 8:33

3 Answers 3

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).

share|improve this answer

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.

share|improve this answer

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.