Applescript to run script in iterm2 tab returns missing value

tell application "iTerm"
    tell current window
        create tab with default profile command "pwd"
    end tell
    tell current window
        create tab with default profile
    end tell
    tell current window
        create tab with default profile
    end tell
end tell

The script above returns 'missing value' when it is runned. It works without command "pwd". Does anyone know what is wrong in this case?


Solution 1:

Not sure why that command fails, however, here is a way that works:

Example AppleScript code:

tell application "iTerm"
    tell current window
        set myNewTab to create tab with default profile
        tell current session of myNewTab to write text "pwd"
        create tab with default profile
        create tab with default profile
    end tell
end tell