discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Running a command using NSTask


From: Csanyi Pal
Subject: Running a command using NSTask
Date: Sun, 21 Nov 2010 09:34:57 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Hi,

I'm trying to run a command from my app using NSTask.
Here is the part od the code:

[code]
- (void) DPbitSetReset: (id)sender
{
  NSSound *DPbitReset = [NSSound soundNamed: @"DPbitReset.wav"];
  NSSound *DPbitSet = [NSSound soundNamed: @"DPbitSet.wav"];

  NSTask *DPSetBit0 = [[NSTask alloc] init];
  [DPSetBit0 setLaunchPath: @"/usr/local/bin/DPSetBit0"];

  // Whether the button state is 1 or 0?
  if ([sender state] == 1)
     {
       // Play the bit set sound
       [DPbitSet play];

       // Which bit to set on Data Port?
       switch ([sender tag])
         {
         case 110: // DPb0sr
           [DPSetBit0 launch];
           [DPSetBit0 release];
           [StatLine setStringValue: @"Write logical 1 to the data port bit 
0."];
           break;
         case 111: // DPb1sr
           [StatLine setStringValue: @"Write logical 1 to the data port bit 
1."];
           break;
[/code]

I can compile my app but when I run it and use this part of my app, that
is when click on the button which has sender tag: 110, the statement
[DPSetBit0 launch]; has no effect. Why?

If I run from the commandline the command '/usr/local/bin/DPSetBit0' it works.

-- 
Regards, Paul Chany
<http://sourceforge.net/projects/lptinterface/>
<http://savannah.nongnu.org/projects/lpt-interface/>
<http://csanyi-pal.info>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]