简体   繁体   中英

Passing arguments to a newly spawned terminal

I am trying to automate some task at work. One of them is to run some aliases, one of which spawns a new terminal, an XTerm from a bash terminal. Now after spawning this terminal, I would need to provide some more commands into this new terminal.

How can this be achieved. One method that I can think of is using expect scripts to handle those tasks. Would this work? if not, are there any methods to run commands on the new terminal.

Edit:

Within the script I found this....

 execcmd="xterm -sb -sl 5000 -T "'`/usr/bin/hostname -s`.$LOADL_STEP_CLASS'" -e $path run_interactive $@

I think this is the one that spawns the new xterm out.. I need to run some commands on this script and then, get whatever it spits out on screen, looking for a particular string like for example "priority-level:" , rest would be simple regex doing the job for me, but I want to automate the interactions with this new xterm that spawned.

PS: I have no straight forward way of passing arguments to this terminal while spawning, without messing up with scripts that many other people are using. so I cannot modify the original alias, maybe write a wrapper around it somehow.

Isn't that what the -e *args* flag to xterm is for? It's going to run whatever you feed it there, so if you modify that argument so that the script or command it invokes also does the extra step you need, you're done.

An alternative is to make the xterm shell a login shell so that your shell startup scripts are invoked, but that will have the side effect of invoking them for every login shell, which might be be suitable in your environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM