Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Screencapture shell script failure...noob

Hi, I'm trying to make a shell script which runs periodically and saves a file with a number appended to it. In order to increment the appended number, I'm saving the mycount variable to a file which is then read in (text file which just stores the number). The file path is pieced together with $mypath $fileName $mycount $fileExt. When I run screen capture from the command line in terminal hand coding the path, it works fine. But even though the path seems correct in the shell script, I get the following error from screencapture:

<Error>: CGImageDestinationCreate destination parameter is nil\n
screencapture: cannot write file to intended destination, ~/Desktop/testCap2.jpg

here's the shell script. I'm sure this is something obvious, but I'm looking at this through noob glasses! 😉 Any help would be greatly appreciated!

TIA, Vince
G5 Quad, 10.5.2

-----------
shell script below
-----------

#!/bin/sh
myPath="~/Desktop/"
fileName="screencapture"
mycount=`cat ~/Desktop/testCount.txt`
mycount=`expr $mycount + 1`
echo $mycount > ~/Desktop/testCount.txt
fileExt=".jpg"
filePath="$myPath$fileName$mycount$fileExt"
screencapture -mx -tjpeg $filePath

G5 Quad, Mac OS X (10.5.2)

Posted on Mar 1, 2008 11:05 AM

Reply
Question marked as Best reply

Posted on Mar 1, 2008 12:14 PM

The problem is in the line:

myPath="~/Desktop/"


For reasons that escape me right now, this doesn't work. Instead, use:

myPath="$HOME/Desktop/"


and it runs fine.
2 replies

Screencapture shell script failure...noob

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.