Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / September 2007



Tip: Looking for answers? Try searching our database.

Problem passing arguments to command line with NSTask

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
none@non.com - 30 Sep 2007 13:25 GMT
Sorry, this is a stupid question, but I just cannot seem to get it to
work right. I'm trying to have the unix command line tool Mencoder work
from my cocoa application. I am using the TaskWrapper.m from Moriarity.

This was my original attempt, which didn't work :

mencoderTask=[[TaskWrapper alloc] initWithController:self
arguments:[NSArray arrayWithObjects:mencoderPath,@"-vf
scale=320:240",[infile stringValue], @"-o",[outfile stringValue],@"-of
avi",@"-ovc lavc",@"-oac lavc",@"-lavcopts
vcodec=mpeg4:vbitrate=230:acodec=mp3:abitrate=64",@"-alang en",nil]];

The result was a complaint that said:

Option vf scale=320:240: unknown postfix  scale=320:240

So i just tried to make it simple,

changing it to this:

     mencoderTask=[[TaskWrapper alloc] initWithController:self
arguments:[NSArray arrayWithObjects:mencoderPath,@"-vf
scale=320:240",nil]];

Again, I get the same error code.

But if I try this in Terminal,

mencoder -vf scale=320:240

It works, and I just get a complaint that I did not enter a file name.

This one:

mencoderTask=[[TaskWrapper alloc] initWithController:self
arguments:[NSArray arrayWithObjects:mencoderPath,@"-ovc lavc",nil]];

also does not work, and the error result is:

-ovc lavc is not an MEncoder option

But it is accepted in Terminal if I say:

mencoder -ovc lavc

So, something I'm doing wrong, but I can't figure it out. I also tried
backslashes in front of the spaces, but that didn't help.

Thanks for any tips
Michael Ash - 30 Sep 2007 14:11 GMT
> Sorry, this is a stupid question, but I just cannot seem to get it to
> work right. I'm trying to have the unix command line tool Mencoder work
[quoted text clipped - 7 lines]
> avi",@"-ovc lavc",@"-oac lavc",@"-lavcopts
> vcodec=mpeg4:vbitrate=230:acodec=mp3:abitrate=64",@"-alang en",nil]];

Read this:

http://www.cocoadev.com/index.pl?NSTaskArguments

The short version is that there is no shell so you need to split up your
arguments more completely. For the long version, read that page. This idea
of where the argument boundaries are is essential for UNIX programming so
hopefully that page will give you some valuable information, not just for
this problem, but for your general experience.

Signature

Michael Ash
Rogue Amoeba Software

none@non.com - 30 Sep 2007 16:10 GMT
> Read this:
>
[quoted text clipped - 5 lines]
> hopefully that page will give you some valuable information, not just for
> this problem, but for your general experience.

Thank you!!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.