I have a script like this:
export P4PORT=192.168.1.132:1666
passwd=`security find-generic-password -ws Exchange | /usr/bin/perl -pe "s/\n//g"`
/usr/bin/expect -c "spawn /Users/myname/bin/p4 login; expect \"Enter password:\"; send \"$passwd\r\"; interact"
res=`/Users/myname/bin/p4 login -s`
osascript <<EOF
tell app "System Events" to display dialog "$res" buttons "OK" default button 1
EOF
which runs perfectly when run as a simple shell script.
When I run it inside Automator on Mac OS X, however, it fails to log in.
The bit that seems to fail is the expect one. If I substitute it with doing things inside terminal in applescript the script works fine. this however is quite an ugly solution - it pops up a terminal and does all the typing in there.
Is the issue really with expect? and can it be worked around?
Since this would have to be implemented as a service, it would be neat to keep it that way.
Thanks.