GUI Shell Script Mac OS X - Working Directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting GUI Shell Script Mac OS X - Working Directory
# 1  
Old 03-18-2011
Error GUI Shell Script Mac OS X - Working Directory

Hi.

I'm pretty new to shell scripting. All I want to do is have a simple shell script that opens a python script from the GUI i.e. when I double click the shell script it will launch the python file. However when I try to do this it looks for the python file in my home directory, I have tried changing the directory in the script but it doesn't work.

The idea behind it is so that I can double click a file rather than having to go to the command line each time and tunnel down to the correct directory but at the same time I'm able to run diagnostics on the program I'm working on.

Is all this wishful thinking? Or can it be done? I thought it would be such a simple problem.
# 2  
Old 03-18-2011
Use Automator on Mac OS X. Create a new application not a workflow.

In Automator under utilities add a run shell script action and underneath it add a run applescript if you want to see your output.

Change the interpreter in the shell script to /usr/bin/python and the input drip down should be set to input as args in the drop down in case you want to drop files on it or open files with your "app".

Type your script in the text box. It should have an example like this already:
Code:
import sys

for f in sys.argv[1:]:
	print f

Change it by adding this line anywhere for testing purposes:
Code:
print "Hello from the shell"

In the applescript action below your shell script action in the applescript action text box there will be an example script like this:
Code:
on run {input, parameters}
	
        (*Your script goes here*)

	return input

end run

Change the return input statement to this:
Code:
on run {input, parameters}
	
	return display dialog item 1 of input buttons {"OK"} default button 1
	
end run

Click the run triangle to test it. You should get a dialog box with an OK button. Click OK. Save the app where ever you want with what ever name you want. Close Automater and double click the app. You should see you dialog.

If everything is working you can now go back into automater and open the app using the open existing workflow from the dialog that pops up or from the file open menu in Automator.

Edit and play to your hearts content. You only need the applescript action if you need to see the results. Like showing the long listing of a directory or some such.

If you are feeling mischievous you can do a show contents on your newly created app and edit the scripts directly.

If you prefer the console you can browse the directory structure of the app you just created in your favorite text editor or by navigating in a terminal window and using cat or less or lynx or links or mc or some such.

Last edited by freegnu; 03-18-2011 at 02:43 PM.. Reason: typo
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

gui based appliocation using shell script

hi, i've to write a shript based application which should gives a look and feel like a GUI. can any one give me a base idea on how to design a GUI based application using shell script. Regards, vijay:b: (1 Reply)
Discussion started by: vij_krr
1 Replies

2. Shell Programming and Scripting

Create A Simple GUI For Shell Script

Hi all! Im wondering if its possible to create a GUI for a shell script I just got done writing as the people that will be using it dont like the command line all to well. Just something simple with radio buttons to select options, maybe a text field to enter a location to save the file generated... (1 Reply)
Discussion started by: Grizzly
1 Replies

3. Shell Programming and Scripting

Interfacing a shell script with Perl Tk GUI

I want to make a GUI in perl tk where I can give some user input. This user input is the command line argument for a shell script. After giving the input parameters I want the user to press a button and the shell script should start executing. How should i interface the shell script with the GUI? (0 Replies)
Discussion started by: lassimanji
0 Replies

4. Shell Programming and Scripting

GUI possible in shell script..?

Hi All, Currently my requirement is to parse through the log scripts and show the errors to the user.The only twist I got is it needs some GUI ,which is considered user friendly. Does anyone has any idea , if GUI can be implemented through shell scripts, please let me know. Thanks! nua7 (5 Replies)
Discussion started by: nua7
5 Replies

5. Solaris

GUI not working... CLI is working fine

Hello, I have X4500 running Solaris 10. I can access it through CLI but I cannot see the GUI. When I reboot it, the GUI works till all the files are loaded (ie., the initial boot sequence) and it prompts me to enter username and password and there it ends. The screen just has a blinking cursor... (4 Replies)
Discussion started by: bharu_sri
4 Replies

6. Shell Programming and Scripting

GUI shell script for Linux

Hi, I want to write shell script file that have a GUI with multiple input box for user entry , i mean multiple input box in one dialog ( window) not one window for each entry , i tried kdialog , and zenity , i didnt find a way to have multiple input box in one window with zenity and kdialog.... (0 Replies)
Discussion started by: mr_aliagha
0 Replies

7. UNIX for Dummies Questions & Answers

Controlling GUI from Shell Script

Hi Everybody, I'm trying to create a script that will launch firefox from a bash shell in ubuntu and perform certain tasks. Why does it have to be a script? Because this firefox must eventually run in a server with xvfb (no gnome, no kde), so I will not have access to it through the GUI. At... (2 Replies)
Discussion started by: rummage_bin
2 Replies

8. Shell Programming and Scripting

Controlling GUI from Shell Script

Hi Everybody, I previously posted this under Unix for dummies and got no answers, so here goes again: I'm trying to create a script that will launch firefox from a bash shell in ubuntu and perform certain tasks. Why does it have to be a script? Because this firefox must eventually run in a... (0 Replies)
Discussion started by: rummage_bin
0 Replies

9. UNIX for Dummies Questions & Answers

If a is windows gui ( client), b is a unix gui ( Server for a) and c is a shell scrip

Hello all, 1) I want to have a GUI application that will call Unix shell scripts, 2) that GUI application should be able to reside on windows ( if possible) and then call Unix shell script either directly or through a server residing on unix. That is for example. If a is windows gui (... (1 Reply)
Discussion started by: hchivukula
1 Replies

10. OS X (Apple)

Deleting from Mac on GUI?

On the Mac, if you delete a file from the GUI, it actually gets moved to a .Trashes folder in your home directory. However, if you rm a file from the terminal application (command line), it is gone for good immediately like in other unix implementations. I would like to see Apple make this... (1 Reply)
Discussion started by: wmosley2
1 Replies
Login or Register to Ask a Question