Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ScKaSx

macrumors regular
Original poster
Feb 27, 2006
105
0
Hi All,

So I'm at a query for the best location to store and use scripts. I'm used to command line binaries which I usually dump in /usr/bin. Since this is in my path, it makes the command line programs convenient to work with from any location. Is there a way to treat scripts in the same manner? I guess I'm looking for script etiquitte.

The script I'm using is to convert pdf to svg to be used in inkscape. Since the pdf's I will use in inkscape are pretty much scattered in my directories it would be nice if I didn't have to move them to employ the script. Any ideas? Thanks

Also does anyone know how I would run this script (pdf2svg.sh) on a file from the commandline:

#################################
#!/bin/bash

# you need gs-common, pstoedit and skencil to
# get this script working
export BASENAME="`basename $1 .pdf`";

# convert PDF to postscript
pdf2ps ${BASENAME}.pdf

# Outline fonts
eps2eps -dNOCACHE ${BASENAME}.ps ${BASENAME}2.ps

# Fix bounding box
ps2epsi ${BASENAME}2.ps ${BASENAME}3.ps

# Convert to Sketch
pstoedit -f sk ${BASENAME}3.ps ${BASENAME}.sk

# Convert to SVG
skconvert ${BASENAME}.sk ${BASENAME}.svg
#################################

I tried " pdf2svg.sh file.pdf " but that wasn't working.

Cheers,
ScKaSx
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
When you enter a command in the Terminal, it looks through several directories to try to find a binary with the same name. The list of these directories is stored in the PATH variable. You can view the contents of this with the 'echo' command
Code:
echo $PATH
To run a script that is not in one of these directories, you need to enter the path of the script relative to the current directory.

When you open a new window in Terminal, by default the current directory is always set to your home directory (/Users/you). If your script was stored in your home directory, you would enter
Code:
./pdf2svg.sh
If it was stored on the Desktop, you would enter
Code:
./Desktop/pdf2svg.sh
There is a way to add on to the PATH variable so that other directories are scanned, however if you have scripts all over the place, it is best to put them in one or two folders together first.
 

angelwatt

Moderator emeritus
Aug 16, 2005
7,852
9
USA
You can also setup aliases, but if you have a lot it could become a less desirable option.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.