Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
Thanks to everyone for helping !!! Using setEnvironment made it easily. I was looking for a complicated solution when the solution was not so difficult. Le 14 avr. 2014 à 17:59, Colas a écrit : > Thanks also for the idea of -setEnvironment. I will try.

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
Unfortunately, it is not working. Gnuplot is complaining. ! Package pgfplots Error: Sorry, the gnuplot-result file ‘myFile.pgf-plot.t able' could not be found. Maybe you need to enable the shell-escape feature? Fo r pdflatex, this is '>> pdflatex -shell-escape'. You can also invoke '>> gnuplo t .g

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
Bryan, I am trying to adapt your code to pdflatex. I hope it will work!!! It seems that putting the option -l at the end was very important. Do you know why? I have to admit that I put these « -c » and « -l » options thanks to other answers, but I don’t know what they are doing. Thanks very muc

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
Le 14 avr. 2014 à 17:07, Bryan Vines a écrit : > Hi Colas, > > Pico is an interactive text editor. I don’t think NSTask is going to give you > much opportunity to interact with it. Are you using Pico as an example, or > are you actually trying to launch Pico? > > If you really *are* trying t

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Bryan Vines
Colas, If my previous code snippet doesn’t work with pdflatex, NSTask has a -setEnvironment method; it may allow you to set your task’s environment variables. — Bryan Vines On Apr 14, 2014, at 10:40 AM, Colas wrote: > My problem is that I want to launch pdflatex with the -shell-escape optio

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Bryan Vines
Colas, Bash’s -c option expects commands in a string which follows. Therefore, this will work: I’m using /usr/bin/touch as an example, rather than your example of pico, which is an interactive text editor. NSTask * myTask = [[NSTask alloc]init]; NSArray * arguments = @[@"-c", @"/us

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas
> Try putting > > /usr/bin/pico /Users/colas/myfile.txt > > into separate items in the argument NSArray. I find the man page ambiguous, > and I lack direct experience, but that may be what bash expects. > > It is not working, unfortunately. > I can’t guarantee that this will solve the large

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Ken Thomases
On Apr 14, 2014, at 10:08 AM, Colas B wrote: > Without the quotes, the error is > Error opening terminal: unknown. Terminal doesn't just run the shell (which, in turn, runs pico). It provides a window and a TTY (terminal device) for the processes to use and translates the I/O to the window. T

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Fritz Anderson
On 14 Apr 2014, at 10:08 AM, Colas B wrote: > OK. > > But without the simple quotes, it also fails. > > With the quotes, the error is > /bin/bash: pico /Users/colas/myfile.txt: No such file or directory > Without the quotes, the error is > Error opening terminal: unknown. > > Thanks! > Le Lund

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas B
OK. But without the simple quotes, it also fails. With the quotes, the error is /bin/bash: pico /Users/colas/myfile.txt: No such file or directory Without the quotes, the error is Error opening terminal: unknown. Thanks! Le Lundi 14 avril 2014 16h19, Jerry Krinock a écrit : From documentation

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Bryan Vines
Colas, Do you want your app to open a Terminal window, in which Pico has opened the file at /Users/colas/myfile.txt? If that’s so, I don’t think launching it via NSTask is going to get you anything. What is the end result you want to achieve? — Bryan Vines On Apr 14, 2014, at 8:59 AM, Colas B

Re: NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Jerry Krinock
From documentation of -[NSTask setArguments:] : "The strings in arguments do not undergo shell expansion, so you do not need to do special quoting” I don’t know what they mean by “special”, but anyhow, the ‘ ' you put around your last argument will be passed to your tool and cause it to fail.

NSTask: how to launch a binary as if I launched it via terminal?

2014-04-14 Thread Colas B
Dear cocoa-dev, I am would like to launch a binary as if I launched it via terminal. I tried the following but it is not working.      NSTask * myTask = [[NSTask alloc] init];     NSArray * arguments = @[@"-c", @"-l", @"'/usr/bin/pico /Users/colas/myfile.txt'"];     [myTask setCurrentDirecto