image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #1  
Old December 17th, 2002, 02:50 PM
buc99's Avatar
Don't Tread on Me!
 
Join Date: Aug 2001
Location: The US of A!
Posts: 386
Thanks: 0
Thanked 0 Times in 0 Posts
buc99 is on a distinguished road
Question Applescript/Terminal Question?

I have a script that asks for a file name and then opens a specific directory and inside the terminal. It then opens vi within the terminal with that filename:

display dialog ¬
"Please enter name of project file:" default answer "samp.c" buttons {"Ok", "Cancel"} ¬
default button "Ok"
if button returned of result = "Ok" then
set z to text returned of result
else
exit repeat
end if
tell application "Terminal"
do script "pushd Sandbox/Programming/Code_src/C"
do script "vi " & z
end tell

The problem here is that (#1, I'm not a very prolific Applescript programmer. But besides that ...) if the terminal is not open this script will open a terminal window, open another terminal window and launch the command "pushd Sandbox/Programming/Code_src/C", and then open another window and execute the command '"vi " & z'. I would like the applescript to just open one terminal window and then launch the two unix commands inside that one single window so that I have only one terminal window open when it is all said and done. One way to get the two commands to execute sequentially in one window is to change the 'do script' lines to:

do script "pushd Sandbox/Programming/Code_src/C; vi " & z

This is basically a Unix fix and I still have two terminal windows open if the Terminal.app is not already active. So how do I accomplish my gaol in a more 'Applescript' kind of way?

Thanks in advance.
SA
__________________
I can do everyhting on my Mac I used to do on my PC, plus alot more.

--Me
Reply With Quote
  #2  
Old December 17th, 2002, 04:27 PM
~departed~
 
Join Date: Jul 2002
Location: Kansas City, MO
Posts: 457
Thanks: 0
Thanked 0 Times in 0 Posts
gatorparrots is on a distinguished road
Remove the tell application "Terminal".
Call your shell commands with:
do shell sript "/path/to/executable -flags"
Reply With Quote
  #3  
Old December 17th, 2002, 07:37 PM
buc99's Avatar
Don't Tread on Me!
 
Join Date: Aug 2001
Location: The US of A!
Posts: 386
Thanks: 0
Thanked 0 Times in 0 Posts
buc99 is on a distinguished road
Nope.

That does not work for the pushd command. All I get is a Terminal window with no change in pwd. i want the first window that pops open to change directories to a specific directory using the "pushd" command.

do shell script "pushd /whatever/Directory/I/Wish/to/Change/to"

This does not work because there is no where to direct the output to the command. This however does do nicely for some unix commands that print their output to the screen(Except top).

Thanks.
SA
__________________
I can do everyhting on my Mac I used to do on my PC, plus alot more.

--Me
Reply With Quote
  #4  
Old December 27th, 2002, 05:21 PM
Registered User
 
Join Date: May 2002
Location: New Zealand
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
scaryfish is on a distinguished road
Stick "in window 1" to the end of your do script commands. Like this:

do script "pushd Sandbox/Programming/Code_src/C" in window 1

And that'll do it in the first window that was opened (or that opens when Terminal launches)
__________________
=)
<><
public key id: EE4B2E09
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A newbie terminal question and a XDarwin question ethanS Unix & X11 4 January 7th, 2003 10:48 AM
OS X Server question mindbend Mac OS X System & Mac Software 1 September 12th, 2002 11:54 AM
Router question and .asf files question simX Apple News, Rumors & Discussion 1 December 18th, 2001 01:51 AM
SMB question NikeiBook Mac OS X System & Mac Software 1 October 20th, 2001 10:17 AM
unix newbie question jmmistrot Mac OS X System & Mac Software 3 October 12th, 2001 02:49 AM


All times are GMT -5. The time now is 08:35 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.