Execution of test script failing in iterm2 session

Hi Everyone, I am new to the forum and KM as well. One of my primary interests with the use of KM is to execute text scripts in an "iterm2" terminal window. When writing the most basic of test scripts the script IS NOT executing in the terminal window. Not sure what I am missing/understanding.

Running Mojava Version 10.14.6
KM Version 9.0.3

I have a macro setup to trigger on 'F1' and also limited to 'iterm2' app. I have a text script defined with a simple 'ls'. When I fire the trigger via 'F1' the output window displays the directory and file content from my MAC rather than the linux box I am iterm2'd onto and is active when firing the trigger.

Not sure where I am going wrong any help would be greatly appreciated. I believe there is a fundamental understanding I am missing.

Jim

The Execute a Shell Script action executes the script, but not in Terminal, nor iTerm, nor any other application.

I don't use iTerm, so I can't suggest how you might execute scripts within it, but others do, so perhaps they could help, or you can search the forum for:

https://forum.keyboardmaestro.com/search?q=iterm

Thank You for the response @peternlewis

I'm not sure of your actual objective, but it looks like it might be that of a text expander.
So if you want to execute:

ls

in the iTerm window, then perhaps something like this would work better:

image

Note that I entered a RETURN after the "ls".

I tested in Terminal and it worked fine.
BTW, if you wish, you can put Macros like this in a Macro Group that is activated ONLY when the iTerm app is frontmost.

Thank You @JMichaelTX !

I have one palette of macros that works with both Terminal and iTerm.

In my case, single line commands all use the Insert Text by Pasting action likeJMichaelTX, more of less. The assumption is that I'm at the command line, of course.

When I want to run two or more commands, I use the Execute Shell Script action, as you attempted. The issue with yours, I'm guessing, is that it's incomplete. All the commands you'd give to get to the linux box's prompt have been omitted so the macro executes on the host system.

In short, both approaches work and have their uses.

Thank You @mrpasini ! I indeed found the "Insert Text by Pasting" action and that seems to be working well. After playing with KM for a few hours I am able to accomplish most tasks using combinations of 'prompts', 'text pasting/typing', and 'clip board storage/pasting/removing' as suggested by respondents. I am using ';' to string multiple commands together.

Thank You All for Your Kind input !

Jim