Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Be careful with 3rd party apps/aliases' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Be careful with 3rd party apps/aliases
Authored by: bluehz on Feb 19, '03 09:38:57PM

You will notice in my script above...

rm $3

that should remove the tmp file.



[ Reply to This | # ]
arguments to shell scripts
Authored by: jzsimon on Feb 20, '03 01:52:09PM
In my shell scripts, I found that using $3 did not give me the file name. Perhaps it's because I use a preset printer setting instead of the standard setting. I get a *very* long $argv, most of which are printer option settings. It is the last argument, "$argv[$#]", that contains the pdf file. Here's the code I use to convert the pdf file to postscript using the pdf2ps (courtesy of fink) command and save the ps file on the desktop:

#!/bin/tcsh
set outDir = ~/Desktop/
set infile = "$argv[$#]"
set outfile = "$outDir""$1:t:r".ps
set logfile = "$outDir""$1:t:r".pdf2ps.log
touch "$logfile"
echo argv:\n$argv >>& "$logfile"
\mv -f "$infile" /tmp/pdf2ps-Tmp.pdf >>& "$logfile"
pdf2ps /tmp/pdf2ps-Tmp.pdf /tmp/pdf2ps-Tmp.ps >>& "$logfile"
\mv -f /tmp/pdf2ps-Tmp.ps ~/Desktop/"$1:t:r".ps >>& "$logfile"
\rm -f /tmp/pdf2ps-Tmp.pdf /tmp/pdf2ps-Tmp.ps >>& "$logfile"
(Note that this code does still has a debugging logfile and does not delete the pdf file as it should.)

[ Reply to This | # ]

arguments to shell scripts
Authored by: bluehz on Feb 20, '03 11:56:48PM

I was trying the same thing with pdf2ps and or ps2pdf and having no luck - it was balking at the file. Any tips?



[ Reply to This | # ]
arguments to shell scripts
Authored by: jzsimon on Feb 24, '03 09:59:21AM

Try my script above for using pdf2ps. It works very nicely for me.

If you have trouble, you can always examine the log file it creates on the Desktop for errors, or problems with which argument (3rd vs. last) contains the file name.

p.s. Despite my last comment in the code posting, it does correctly remove the temp pdf file.



[ Reply to This | # ]
arguments to shell scripts
Authored by: ssevenup on Feb 26, '03 05:41:23PM

I get "TERM_PROGRAM: Undefined variable." in the Console log.

---
Mark Moorcroft
ELORET Corp. - NASA/Ames RC
Sys. Admin.



[ Reply to This | # ]
arguments to shell scripts
Authored by: jzsimon on Feb 26, '03 05:59:20PM

That's a different problem. Read this (and comments) to solve that bug:
http://www.macosxhints.com/article.php?story=20020826003806202



[ Reply to This | # ]
arguments to shell scripts
Authored by: ssevenup on Feb 27, '03 04:17:23PM

Thanks for the tip, I solved that and now unless I comment out the line that dumps arg#2 into the log, the script pukes with "unknown user ./" or some such after dumping the majority of the CUPs arguments. Otherwise I can produce a .ps file, and even pipe it back through ps2pdf. I am posting a seperate note on that subject. By the way the tips for setting up the tcsh environment worked, but I had a heck of a time forcing the path to include "/usr/local/bin". I actually had to add it with ~/Library/init/tcsh/rc.mine because it wasn't getting picked up as expected?

---
Mark Moorcroft
ELORET Corp. - NASA/Ames RC
Sys. Admin.



[ Reply to This | # ]
oops: arguments to shell scripts
Authored by: jzsimon on Feb 25, '03 12:25:55AM

Oops. $argv[$#] is the same thing as $3 in this case. I didn't realized that $2 was a single argument of many space-separated strings.

I blame apple for making their documentation hard to find. ;)



[ Reply to This | # ]