Link to home
Create AccountLog in
Avatar of desiredforsome
desiredforsome

asked on

Remove substring .net

I have a ssh tunnel that send the following command

"netstat -ntl |grep 4400"

It returns it to a string, here is my issue

I am doing this to check for open ports on remote ends, I need the string that comes back to not have the "netstat -ntl |grep 4400" in it.

I just need it to remove that 1 command from the string but display all other information.


Thank You In Advanced.

Writing in VS 2010 c#, VB
ASKER CERTIFIED SOLUTION
Avatar of Member_2_99151
Member_2_99151

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Rick
Rick

Is 4400 the port number?

let's say that you're checking other ports too:
 
      "netstat -ntl |grep 4400"
      "netstat -ntl |grep 900"
      "netstat -ntl |grep 80"
       ...

and that you have a string called "returnString" that is returning something like:

      "netstat -ntl |grep 4400 Bla, Bla, Bla A..."
      "netstat -ntl |grep 900 Bla, Bla, Bla B..."
      "netstat -ntl |grep 80 Bla, Bla, Bla C..."

you could do something like (VB):

        returnString = returnString.Replace("netstat -ntl |grep ", "")
        returnString = returnString.Substring(InStr(returnString, " "), returnString.Length - InStr(returnString, " "))


this will return:

      "Bla, Bla, Bla A..."
      "Bla, Bla, Bla B..."
      "Bla, Bla, Bla C..."