func checkArguments() {

	incorrect := false
	// need 3 arguments device tcp port header
	if len(os.Args) != 4 {
		fmt.Println("not enough parameters, 3 are needed")
		showUsage()
	}
	// check if arguments are correct
	device = os.Args[1]
	if device == "" {
		fmt.Println("device is empty, please choose one of the following :")
		fmt.Println(execShellCommand(`ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d'`))
		incorrect = true
	}

	bindedPort = os.Args[2]
	if _, err := strconv.Atoi(bindedPort); err != nil {
		fmt.Println(bindedPort, "is not a correct TCP port, please choose one of the following :")
		fmt.Println(execShellCommand(`netstat -pnl`))
		incorrect = true
	}

	header = os.Args[3]
	if header == "" {
		fmt.Println("header is empty")
		incorrect = true
	}
	if incorrect {
		showUsage()
	}
	pattern = strings.Join([]string{header, ":(.*)"}, "")
}
// check if all arguments are not empty and correct
check if all arguments are not empty and correct
// check if all arguments are not empty and correct
func checkArguments() {
	incorrect := false
	if len(os.Args) != 4 {
		fmt.Println("not enough parameters, 3 are needed")
		showUsage()
	}
	device = os.Args[1]
	if device == "" {
		fmt.Println("device is empty, please choose one of the following :")
		fmt.Println(execShellCommand(`ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d'`))
		incorrect = true
	}
	bindedPort = os.Args[2]
	if _, err := strconv.Atoi(bindedPort); err != nil {
		fmt.Println(bindedPort, "is not a correct TCP port, please choose one of the following :")
		fmt.Println(execShellCommand(`netstat -pnl`))
		incorrect = true
	}
	header = os.Args[3]
	if header == "" {
		fmt.Println("header is empty")
		incorrect = true
	}
	if incorrect {
		showUsage()
	}
	pattern = strings.Join([]string{header, ":(.*)"}, "")
}
func checkArguments ( ) { incorrect := false if len ( os . Args ) != 4 { fmt . Println ( " " ) showUsage ( ) } device = os . Args [ 1 ] if device == " " { fmt . Println ( " " ) fmt . Println ( execShellCommand ( `ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d'` ) ) incorrect = true } bindedPort = os . Args [ 2 ] if _ , err := strconv . Atoi ( bindedPort ) ; err != nil { fmt . Println ( bindedPort , " " ) fmt . Println ( execShellCommand ( `netstat -pnl` ) ) incorrect = true } header = os . Args [ 3 ] if header == " " { fmt . Println ( " " ) incorrect = true } if incorrect { showUsage ( ) } pattern = strings . Join ( [ ] string { header , " " } , " " ) }
check if all arguments are not empty and correct
check if all arguments are not empty and correct
// need 3 arguments device tcp port header // check if arguments are correct