We help IT Professionals succeed at work.

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
Comment
Watch Question

Can you not use

String newString = oldString.Replace("netstat -ntl |grep 4400", "");

where oldString is the original one...

James

Commented:
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..."

Explore More ContentExplore courses, solutions, and other research materials related to this topic.