Python Forum

Full Version: I gotta problem with making argv parameters
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
[color=#333333][size=small][font=monospace,]#!/usr/bin/env python
import socket
import subprocess
import sys
import argparse
from socket import *

def scanner(host, port):
 boz = connect(host, port)
 if boz:
 print("acik")
 else:
 print("kapali")

def main():
 parser = argparse.Argumentparser()
 parser.add_argument("-w", dest='server')
 parser.add.argument("-p", dest='port', type=int)
 args = parser.parse_args()
 
 if args.server and args.ports:
 for port in args.ports:
 scanner(gethostbyname(args.server), port)
 else
 print("sikinti var")
 
if __name__ == '__main__' :
 main()[/font][/size][/color]
here is my code and i want to make it like "python x.py google.com 80" and i want to scan.
Thanks for help  <3
your code:
 parser.add_argument("-w", dest='server')
 parser.add.argument("-p", dest='port', type=int)
so looks like you forgot to add these in your command
You have parser.add.argument("-p", dest='port', type=int) but args.ports in the if statement.
The last else is missing :