Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Sep 15, 2008, 11:42 PM   #1
chidambaram
macrumors member
 
Join Date: Mar 2008
Permission denied problem

hi,

I am working in Carbon C application (Mac OS 10.4.7)

I want to open a pdf file which is placed in the desktop using System command.

My code is

system("/Users/laserwords/Desktop/test1.pdf");

The output is permission denied

What can i do to rectify this?

Thanks in advance....
chidambaram is offline   0 Reply With Quote
Old Sep 16, 2008, 12:09 AM   #2
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: Dallas, TX
That isn't an executable file. You'll need to choose the program and pass the file as an argument, or use some other method to launch the file in the default application. I'm not sure how to do the latter with carbon.

-Lee
lee1210 is offline   0 Reply With Quote
Old Sep 16, 2008, 12:37 AM   #3
chidambaram
Thread Starter
macrumors member
 
Join Date: Mar 2008
thanks for ur reply sir.

You said "choose the program and select the file"

Will u please explain this in detail and how can i do that?
chidambaram is offline   0 Reply With Quote
Old Sep 16, 2008, 04:55 AM   #4
gnasher729
macrumors G5
 
gnasher729's Avatar
 
Join Date: Nov 2005
Quote:
Originally Posted by chidambaram View Post
My code is

system("/Users/laserwords/Desktop/test1.pdf");
1. This call to the "system" function would try to execute the file test1.pdf. Which you obviously can't, and if you could, you wouldn't want to.

2. Since there is another thread about buffer overflows and security problems, I'd just say that the system function can lead to some rather nasty security holes.

3. Have a look at the LaunchServices APIs. Especially LSOpenCFURLRef and LSOpenFSRef.
gnasher729 is offline   0 Reply With Quote
Old Sep 16, 2008, 07:14 AM   #5
robbieduncan
Moderator
 
robbieduncan's Avatar
 
Join Date: Jul 2002
Location: London
Everything gnasher729 said above is correct and you should really do 3) but if you want a quick and dirty fix try using

Code:
system("open /Users/laserwords/Desktop/test1.pdf");
This should call the command line open utility that will use Launch Services to open the file in the correct application...
robbieduncan is offline   0 Reply With Quote
Old Sep 16, 2008, 08:14 AM   #6
chidambaram
Thread Starter
macrumors member
 
Join Date: Mar 2008
thanks for ur reply

system function with open keyword is working fine.

please give some sample code for LSOpenFSRef() and LSOpenCFURLRef()
chidambaram is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Permission denied to access property 'document' - Javascript error dsproffitt iCloud and Apple Services 0 Apr 3, 2014 02:02 AM
ssh localhost Permission Denied mkw5053 OS X 0 Jul 24, 2013 04:22 PM
sudo: can't open /private/etc/sudoers: Permission denied ryannazaretian OS X 10.8 Mountain Lion 3 May 25, 2013 10:33 PM
Access to Shared Folder denied permission Plado MacBook 2 Mar 16, 2013 03:26 PM
Terminal Permission Denied Greeting Ed91 OS X 2 Aug 1, 2012 03:54 AM

Forum Jump

All times are GMT -5. The time now is 03:58 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC