Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8927609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:15:22+00:00 2026-06-15T08:15:22+00:00

I have compiled a script in python 2.6.5, The script is simply to automate

  • 0

I have compiled a script in python 2.6.5, The script is simply to automate my most used functions for nmap and log the output to a txt file on the desktop.
I haven’t written this all myself as i am still only learning python. I found an update script for updating backtrack and used that as a template for indentation and commands and modified it and added some of my own stuff to give me what i needed.

The problem i’m having is with this block

def nmap_target():


    try:    ip = raw_input(" [>] Enter ip to scan:  ")

except KeyboardInterrupt:
    print "\n [>] Exiting!\n"
            sleep(1)
    sys.exit()
    print " [>] Attempting targeted scan.\n"
    #print ip 
if subprocess.Popen("nmap ip >> //root/Desktop/Target.txt && tail /root/Desktop/Target.txt",shell=True).wait() == 0:
    print "\n"
    print " [>] Targeted scan completed successfully!\n"
            menu_main()

else:
    print "\n"
    print " [>] Nmap scan failed.\n"

The idea behind it is that it asks the user to input an ip address into raw_input() and call it ip, I’m trying to then pass it to nmap using subprocess.Popen(“nmap ip as can be seen above.
The problem is its just writing nmap ip rather than printing the ip address and then returning errors, It even tries to scan out of my network, every time i test it i make sure the internet cable is unplugged from my router, This causes a bug with my internet test though, so if you try running the code bellow you may need to hash out the internet_check() option in the menu_main() section if you have your internet unplugged from the router

I have spent 4 days on this now and its driving me mad, At first i thought i needed to convert the number to floating point so i tried that and still the same, I’ve tried all sorts of things and spent hours trawling the internet looking for an answer to no avail.

I am now convinced its not the command i’m trying that is to blame i think it is the exit statement, I have tried putting “print ip” right after the line where it says “print ” [>] Attempting targeted scan.\n” and sure enough the ip address that was entered is displayed on the screen, That proved to me that raw_input() is working. As soon as i move it anywhere bellow that it fails, This suggests to me that it must be either a problem with the exit statement or maybe indentation, I’m not sure though.
I have also tried hashing out the keyboard interrupt as well as the couple of lines bellow, i tried moving the try: and if statements around and even tried other commands instead but it just wont work aaaarrrrrgggghhhhhh

Would i be right in thinking that the ip is being entered into raw_input() and then the file ip that was created that holds the ip address is being destroyed before i can pass it to subprocess.Popen(“nmap ip.

Like i mentioned i didn’t write this script from scratch and this is my first project like this so i’ve got a lot to learn, I’ve been all through the python man pages and looked through all sorts of tutorials but just can’t figure this out.
Any help will be much appreciated

i will post the full script if anyone is interested,just as soon as i can figure out how to post code properly

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T08:15:23+00:00Added an answer on June 15, 2026 at 8:15 am

    You need to seperate the variable from the string! Try this 😀

    if subprocess.Popen('nmap '+ip+' >> //root/Desktop/Target.txt && tail /root/Desktop/Target.txt',shell=True).wait() == 0:
    

    Hope it helps!

    EDIT – If for some reason python takes the raw input as an integer, convert it to string like so:

    if subprocess.Popen('nmap '+str(ip)+' >> //root/Desktop/Target.txt && tail /root/Desktop/Target.txt',shell=True).wait() == 0:
    

    Python doesn’t like to concatenate str and int types, or so it tells when my script fails 😛 I am pretty sure your ip variable will be str type though so the first example should work.

    Cheers!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a script in python to process a log file - it parses
I have a compiled .NET assembly with a specific resource file embedded (named 'Script.xml').
I have written a Python script and compiled it into a MS Windows EXE
I have a Python script that takes the directory path of a text file
So I have compiled a python script with py2exe according to this answer .
Is there any batch script compiler available? I have a very big batch file
I have compiled my preload file on Ubuntu server (two files for x32 and
I have a Python script that we're using to parse CSV files with user-entered
I'm writing a python script that uses subprocess.Popen to execute two programs (from compiled
I have a simple python script import _tph str = u'Привет, <b>мир!</b>' # Some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.