Python Forum
I gotta problem with making argv parameters
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I gotta problem with making argv parameters
#1
[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
Reply
#2
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
Reply
#3
You have parser.add.argument("-p", dest='port', type=int) but args.ports in the if statement.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#4
The last else is missing :
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I call sys.argv list inside a function, from the CLI? billykid999 3 795 May-02-2023, 08:40 AM
Last Post: Gribouillis
  sys.argv method nngokturk 3 1,089 Jan-23-2023, 10:41 PM
Last Post: deanhystad
  import argv Scott 3 5,906 Apr-01-2021, 11:03 AM
Last Post: radix018
  use of sys.argv deepakkr3110 3 3,051 Nov-29-2019, 05:41 AM
Last Post: buran
  Not all data returned from sys.argv ecdhyne 2 2,769 Sep-05-2019, 08:27 PM
Last Post: buran
  Pyinstaller with Sys.Argv[] - “Failed to Execute Script”? ironfelix717 0 5,312 Aug-07-2019, 02:29 PM
Last Post: ironfelix717
  I see is that sys.argv contains character strings helenharry 2 2,759 Jan-09-2019, 11:34 AM
Last Post: DeaD_EyE
  How argv works? Philia 7 4,842 Dec-26-2018, 12:20 AM
Last Post: metulburr
  sys.argv correct sintax? enricosx 3 3,215 Jul-25-2018, 09:27 AM
Last Post: buran
  argv IndexError hsunteik 2 4,539 Dec-19-2016, 06:19 AM
Last Post: hsunteik

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020