Mac Forums

Mac Forums (http://www.mac-forums.com/forums/)
-   OS X - Development and Darwin (http://www.mac-forums.com/forums/os-x-development-darwin/)
-   -   Shell scripting (http://www.mac-forums.com/forums/os-x-development-darwin/41114-shell-scripting.html)

badmuthahubbard 09-08-2006 02:02 PM

Shell scripting
 
I want to put my program in a folder with some other stuff, including a .command file that will run the programming environment my program uses, tell it to open my program, and send it some flags.
I would like to set up the .command file so that it knows the path from which the commandline is called; ie, the path to the command file itself, so that a user can put this folder anywhere they like and be able to run it.

I also can't get the commandline to pass flags to the programming environment executable. This is the commandline I'm using, that should work:

####
#! /bin/sh

../Shared/Documents/CSHJr/JIsequencershare/Pd-0.39-2.app/Contents/MacOS/Pd -font 36
####

Now if I just take off the -font flag, it opens Pd fine. But like this, it says:

=========
Last login: Fri Sep 8 13:51:57 on ttyp1
/Users/Shared/Documents/CSHJr/JIsequencershare/JI.command; exit
Welcome to Darwin!
AC-T1212-M13:~ student$ /Users/Shared/Documents/CSHJr/JIsequencershare/JI.command; exit
retrying connect...
retrying connect...
retrying connect...
retrying connect...
retrying connect...
retrying connect...
retrying connect...
retrying connect...
retrying connect...
connecting stream socket: Invalid argument (22)
logout
[Process completed]
==========

I checked out the open, exec, and chflag commands, none of them seem to help. I would also like to replace that huge path to the executable with some sort of environment variable giving the path to where the command is called from.

Are either of these requests possible?

xstep 09-13-2006 04:16 AM

I'm not really sure what your looking for, but try the below sample. Don't forget to make it executable.

I named the script test.sh in my root directory, cd'd to /tmp, and typed;
~/test.sh -font 35


#!/bin/sh

echo $0 #this is the path as typed to run this script.
echo $1 $2 #there are the two variables passed in

mypwd=`pwd` #get the present working directory the user executed this from.
echo $mypwd #echo the present working directory.

exit


All times are GMT -4. The time now is 10:24 PM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.