1
on run argv
    set scpt to first item of argv
    tell application "Terminal"
        do script "bash " & scpt
        activate
    end tell
end run

the issue is no matter what script command I tell it to do it always prints that command in terminal first. I don't want this echo behavior how do I disable it with using AppleScript.

Edit 1: this is a good example of pure AppleScript logic and the output looks horrible. Now while your able to do set +v bash command to turn the echo off let's say echo foo was a really long command clearing the screen causes a flicker. I am asking how to enable echo off or set +v without causing an echo to begin with?

tell application "Terminal"
    set a to do script ""
    activate
    do script "echo foo" in a
    do script "echo ardvark" in a
end tell

Edit 2: I tried using the set +v from bash with clear and it wasn't maintained

tell application "Terminal"
    set a to do script ""
    activate
    do script "bash -c \"set +v\" ; clear" in a
    do script "echo foo" in a
    do script "echo hello world" in a
end tell
jredfox_
  • 19
  • 6
  • Is there a particular reason for using Terminal (output, etc)? – red_menace May 31 '22 at 13:23
  • running do shell script won't display a UI @user3579815 – jredfox_ Jun 01 '22 at 07:20
  • A `.command` file will also run the shell script in the Terminal, but I’m trying to figure out why you would be using a shell script/Terminal command to call `osascript` to run an AppleScript to do a script in Terminal? – red_menace Jun 01 '22 at 13:55
  • @red_menace `.command` still echos the command on boot. I want basically a clear screen with the UI of terminal like it's suppose to run scripts but do It from AppleScript as running an app calling a command will simply execute it without a UI. – jredfox_ Jun 01 '22 at 14:15
  • How about [clearing the screen](https://stackoverflow.com/q/2198377/10853463)? – red_menace Jun 01 '22 at 14:39
  • @red_menace clearing the screen after ever command isn't good idea either. And the screen flickers it looks bad – jredfox_ Jun 02 '22 at 09:59
  • There are also a variety of terminal emulator commands and escape codes to do stuff such as backspace, move the cursor around, set bold/colors, etc. This would seem to be one of those situations where it helps to go into excruciating detail about what you are trying to accomplish. – red_menace Jun 02 '22 at 18:00
  • @red_menace I just showed another good example on why clearing the screen isn't a good idea – jredfox_ Jun 11 '22 at 06:40

1 Answers1

0

Not sure that I understand your question/need exactly but from what I can tell I had the opposite need and so, reading your question solved mine.

# launch application
tell application "Terminal"
    set a to do script "/path/script.sh"
    activate
end tell

Output is echoed to terminal

# launch application
tell application "Terminal"
    activate
    do shell script "/path/script.sh"
end tell

No output is echoed to terminal

XJMZX
  • 21
  • 2
  • Note that `do shell script` is not a Terminal command. – red_menace Jan 16 '23 at 20:15
  • I wasn't aware of that. I guess then it's not appropriate. I simply read "I am asking how to enable echo off ..?" I thought it disables it, maybe not though. "/bin/sh is really bash emulating sh." [link](https://developer.apple.com/library/archive/technotes/tn2065/_index.html#//apple_ref/doc/uid/DTS10003093-CH1-TNTAG1-WHY_DOESN___T_DO_SHELL_SCRIPT_WORK_EXACTLY_LIKE_TERMINAL_) – XJMZX Jan 16 '23 at 22:07
  • `do shell script` is from Standard Additions and uses its own shell - it doesn’t have anything to do with the Terminal, and is mainly used to avoid it. – red_menace Jan 16 '23 at 22:12