how to write properly terminal command in objective c -


i have run command kill process , command kill pgrep -f /dev,i know run command nstask used how run above command these special arguments , pgrep -f /dev in `` have tried code

nstask *task = [[nstask alloc]init];  [task setlaunchpath:@"/bin/kill"];  [task setarguments:@[@"`",@"pgrep",@"-f",@"/dev",@"`" ];  [task launch]; 

please tell how write properly,i know have given arguments wrong. thanks, highly appreciated.

your problem appears lie in misunderstanding how command line handled. when type line:

kill `pgrep -f /dev` 

you typing shell, bash tcsh etc. quotes (`) shell feature; shell arrange run both commands , take output of pgrep , pass arguments kill.

in code attempting execute kill , pass arguments quoted pgrep command. won't work, kill knows nothing quotes, shell feature...

so read shell documentation (man sh) , discover can pass shell command line single argument shell command - can try in terminal yourself. having figured out can use nstask code run shell, passing command line.

hth


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -