Re: netstat launched from within Cocoa?
Re: netstat launched from within Cocoa?
- Subject: Re: netstat launched from within Cocoa?
- From: Lorenzo <email@hidden>
- Date: Wed, 23 Apr 2003 19:45:33 +0200
netstat -f inet -n | grep '169.254.180.151' | grep ESTABLISHED | awk '{
print $5 }'
Hi, the line above works well on the Terminal. I get all the IP ESTABLISHED
connections to my machine IP 169.254.180.151.
After you suggested where is netstat, now it works, thank you, but I cannot
yet pass all the arguments from Cocoa very well. I guess that there should
be a different method to grep the result, anyway the following code doesn't
grep. It produces a common netstat -f inet -n list.
NSPipe *myPipe = [NSPipe pipe];
NSArray *arguments = [NSArray arrayWithObjects:@"-f", @"inet", @"-n",
@"| grep '169.254.180.151'",
@"| grep ESTABLISHED",
@"awk '{ print $5 }'", nil];
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/sbin/netstat"];
[task setArguments:arguments];
[task setStandardOutput:myPipe];
[task launch];
[task waitUntilExit];
... etc
So please, how should I grep the result?
Best Regards
--
Lorenzo
email: email@hidden
>
From: Tom Sutcliffe <email@hidden>
>
Date: Wed, 23 Apr 2003 17:34:20 +0100
>
To: Lorenzo <email@hidden>
>
Cc: <email@hidden>
>
Subject: Re: netstat launched from within Cocoa?
>
>
/usr/sbin/netstat
>
>
but you can type
>
which netstat
>
into the Terminal to get any command's full path (providing the command
>
is in the PATH somewhere)
>
>
Regards,
>
>
Tom
>
>
On Wednesday, April 23, 2003, at 04:56 pm, Lorenzo wrote:
>
>
> Hi,
>
> how could I launch the unix command "netstat" from within a Cocoa
>
> application?
>
>
>
> I already can launch other commands like "ls -l" using:
>
>
>
> NSTask *task = [[NSTask alloc] init];
>
> [task setLaunchPath:@"/bin/ls"];
>
> NSArray *args = [NSArray arrayWithObjects:@"-1", myFolder, nil];
>
> [task setArguments:args];
>
> [task setStandardOutput:myPipe];
>
> [task launch];
>
>
>
> But now I cannot find the pathname of the command "netstat"
>
> So, what should I call? How to do?
>
>
>
> At the end, just to say, all I really need is to get the URL of a
>
> mounted
>
> remote volume. And if the volume URL is Samba as
>
> "smb://1.2.3.4/VolumeName"
>
> the other APIs don't work properly, so I have to workaround the problem
>
> using netstat. But, where is the netstat file?
>
>
>
> Best Regards
>
> --
>
> Lorenzo
>
> email: email@hidden
>
> _______________________________________________
>
> cocoa-dev mailing list | email@hidden
>
> Help/Unsubscribe/Archives:
>
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.