Need Help On Terminal!!!! & Progress Bar!

NOTE: I THINK THIS SHOULD OF BEEN PUT IN CODE EXCHANGE?!?!?

OK WHAT I’M TRYING TO ACHIVE IS TO MAKE A LITTLE PROGRAM FOR MYSELF THAT DOES A TERMINAL COMMAND AND THEN WHEN FINISHED DISPLAY A DIALOG SAYING “COMPLETED”

SO SOMETHING LIKE THIS:


set my theRepairstatusmessage to "Repairing Mac OS X..."
        delay 1.0
        set my theRepairstatusmessage to "[Please Wait!]"
        delay 1.0
        set my theRepairstatusmessage to "Repairing Mac OS X..."
        delay 1.0
        set my theRepairstatusmessage to "[Please Wait!]"
        delay 1.0
    tell application "terminal" to "/bin/date '+%a %b %e %H:%M' >> " & outFile & ";diskutil repairPermissions / >> " & outFile & ";echo '=-=-=-' >> " & outFile & ";/usr/bin/open " & outFile 
       -- do shell script "/bin/date '+%a %b %e %H:%M' >> " & outFile & ";diskutil repairPermissions / >> " & outFile & ";echo '=-=-=-' >> " & outFile & ";/usr/bin/open " & outFile
       -- set my theRepairCounter to 
        set my theRepairstatusmessage to "Repairing Mac OS X..."
        delay 1.0
        set my theRepairstatusmessage to "[Please Wait!]"
        delay 1.0
        set my theRepairstatusmessage to "Repaired! Mac OS X."

BUT I DONT WANT THE REPAIRED MAC OS X DIALOG TO SHOW UNTIL THE COMMAND IS 100% FINISHED!!! PLEASE HELP AND CREDITS WILL GO IN THE ABOUT BOX!!!

Please press your Caps Lock key

PS:

To answer your question:
As AppleScript is single-threaded by default, you need a second thread to perform the shell script asynchronously.
In (AS)ObjC this can be done with NSTask, NSPipe and NSFileHandle.
This is an example in Objective-C to display all output of a shell call asynchronously


- (IBAction) start:(id)sender {
	task = [[NSTask alloc] init];
	// Setup the pipes on the task
	NSPipe *outputPipe = [NSPipe pipe];
	NSPipe *errorPipe = [NSPipe pipe];
	[task setStandardOutput:outputPipe];
	[task setStandardInput:[NSFileHandle fileHandleWithNullDevice]];
	[task setStandardError:errorPipe];
	
	[task setArguments:[NSMutableArray arrayWithObject:@"repairPermissions"]];
	[task setLaunchPath:@"/usr/sbin/diskutil"];
	
	[[NSNotificationCenter defaultCenter] addObserver:self 
											 selector:@selector(getData:) 
												 name: NSFileHandleReadCompletionNotification 
											   object: [[task standardOutput] fileHandleForReading]];
	
	[[[task standardOutput] fileHandleForReading] readInBackgroundAndNotify];
	[task launch];
}


- (void) getData: (NSNotification *)aNotification
{
    NSData *data = [[aNotification userInfo] objectForKey:NSFileHandleNotificationDataItem];
    if ([data length])
		[self displayData:data];
    } else {
        [self stopProcess];
    }
    [[aNotification object] readInBackgroundAndNotify];  
}

- (void)stopProcess
{
    NSData *data;
    [[NSNotificationCenter defaultCenter] removeObserver:self 
    									name:NSFileHandleReadCompletionNotification 
									object: [[task standardOutput] fileHandleForReading]];
    [task terminate];
	while ((data = [[[task standardOutput] fileHandleForReading] availableData]) && [data length])
	{
		[self displayData:data];
	}
	[task release];
}

- (void)displayData:(NSData *)readData
{
	NSString *readString = [[NSString alloc] initWithData:readData 
								encoding:NSUTF8StringEncoding];
	if (readString) {
		// do something;
		[readString release];
	}
}


I don’t think it is necessary to place code like this is in code exchange. diskutil is the cli version of disk utily application and they uses the same frameworks. SO if someone wants a GUI, use disk utiliy instead of terminal.

Then in unscripted I have posted how to make background processes and manage them.