codenamepenryn
codenamepenryn

Reputation: 461

Command works in shell but not Objective-C or C

I want to run the following shell command in Objective-C

sshfs -C -p 22 [email protected] ~/local/directory/path

using the command system("sshfs -C -p 22 [email protected] ~/local/directory/path");

but I get sh: sshfs: command not found in NSLog.

If I copy and paste it into terminal however, it works.

Upvotes: 0

Views: 93

Answers (1)

mmmmmm
mmmmmm

Reputation: 32710

The path used by an GUI application does not include any changes you have made in your shell files in your home directory (e.g. ~/.bashrc)

One way is to use the full path in the system call. (i.e. /Users/username/Projects - ~ are not automatically expanded) In a Cocoa app I would use NSTask to give more control

Upvotes: 2

Related Questions