Question

I have a script which I am making to start two applications which I have created. One is a command line interface and the other is the application itself.

output/a.o
output/b.o

I have a start shell script which does the following.

#!/bin/bash    
./output/a.o & 
sleep 3;
open -a Terminal.app output/b.o

So the shell script starts the two applications. b.o relies on a file generated by a.o at runtime which has some configuration parameters for the command line interface. The issue I have is that the first program is executed in the current working directory, however the second command which opens the command line interface in a new window opens it in the /Users/Username directory or the HOME directory for the current user. Because of this the second application b.o cannot find the file which is generated in the current working directory where a.o is running.

I was wondering if anyone would know a way to execute the command line interface (b.o) using the open command in the same current working directory as a.o (the application).

NOTE: I don't want to use open for both the scripts as I would like the scripts to be run from the current working directory and not the home directory of the user.

Was it helpful?

Solution

I would recommend trying AppleScript instead of open for this -

osascript -e 'tell application "terminal"' -e 'do script "cd /path/to/direcory; output/b.o"' -e 'end tell'

This should open a new terminal window, cd to the correct directory then run your program.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top