Teaching Myself Python. How Can I Stop The Program From Closing :)

I wrote a program today that will log into a router here at work and check if the line protocols are up and if i can see thir mac address.  If i run it from the IDLE program it works fine.  When i run it as just crosnet.py it runs fine but closes before i can see the output.  I imagine there is some simple line that will have run and just sit?  Or even better, loop back to the beginning and wait for me to give it a new number to then telnet with.
#import getpass
import sys
import telnetlib
HOST = "111.111.111.111"
password = "password"
vpc = raw_input("Enter The VPC Number: ")
#password = getpass.getpass()
tn = telnetlib.Telnet(HOST)
#tn.read_until("login: ")
#tn.write(user + "\n")
#if password:
tn.read_until("Password: ")
tn.write(password + "\n")
#tn.write("sh int atm6/0.vpc\n")
tn.write("sh int atm6/0." + str(vpc) + "\n")
tn.write("sh arp | in " + str(vpc) + "\n")
#tn.write("exit\n")
print tn.read_all()
Sorry the code is bad, dont know python and i was shown a outline of how to telnet and adjusted it to my needs.

while True:
and just indent everything else under it
Ends when you press ^C.
if you wish to have a way to break out of the loop, say, when you press enter at the VPC number without entering anything, add the following after your vpc input:
if not vpc:
break
which will break out of the while loop and end your program.
Last edited by buttons (2007-12-14 22:03:06)

Similar Messages

  • How can I stop the program from going through all of the text previously put in.  It is making the process very slow.

    How can I stop the program from going through all of the text previously put in.  It is making the process very slow. 

    while True:
    and just indent everything else under it
    Ends when you press ^C.
    if you wish to have a way to break out of the loop, say, when you press enter at the VPC number without entering anything, add the following after your vpc input:
    if not vpc:
    break
    which will break out of the while loop and end your program.
    Last edited by buttons (2007-12-14 22:03:06)

  • How can I stop a JFrame from closing when clicking the close button.

    I need to display a dialog when a user attempts to close my app, giving them the option to close, minimize or cancel. How can I stop the form from closing after the user makes his selection? I have the folllowing code, but my form still closes after selecting an option:
    private void formWindowClosing(java.awt.event.WindowEvent evt) {                                  
            //An array of Strings to be used a buttons in a JOptionDialog
            String[] options = {"Close", "Minimize", "Cancel"};
            //Determines what the user wants to do
            int result = JOptionPane.showOptionDialog(null, "What to you want to do?  Close the application, minimize or cancel?", "Please select an option...", 0, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
           //Determines what to do, depending on the user's choice
            if (result == 0) {
                //Close the application
                System.exit(0);
            } else if (result == 1) {
                //Minimize the application
                this.setState(Frame.ICONIFIED);
        }Any help would be much appreciated!

    import java.awt.event.*;
    import javax.swing.*;
    public class test extends JFrame {
         public static void main( String[] args ) {
              new test();
         public test() {
              setSize( 200, 200 );
              //the next line makes the JFrame not close
              setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE );
              //now add a listener that does the trick
              addWindowListener( new WindowAdapter() {
                        public void windowClosing( WindowEvent e ) {
                             //ask the user and do whatever you wish
              setVisible( true );
    }

  • When I record an audio track, there is a waveform. When I stop recording, the waveform disappears and becomes a straight line. It also disappears from the track edit window. But the sound is there. How can I stop the waveform from disappearing?

    When I record an audio track using Logic Pro X, there is a visible waveform which appears as I record. When I stop recording, the waveform disappears and becomes a straight line. It also disappears from the track edit window. But the sound is still there. How can I stop the waveform from disappearing? And can I do something to view it after it has disappeared? Anyone know the anser?

    In Logic:
    Preferences/Audio Set Recording Delay to 0 <zero>
    This should always be set to zero unless a specific set of circumstances exist and you're audio drivers do not report position correctly.
    On occasion, usually when importing a Logic 9 project, Logic-X randomly changes this to a negative/positive number.  It's actually a bug in Logic, as it should always display the waveform.

  • Hi...I have this problem, everytime I want to print something out the mac asks me for the computer password...that is really becoming annoying after. That happened since I upgraded to mountain lion. How can I stop the computer from asking me that?

    Hi...I have this problem, everytime I want to print something out the mac asks me for the computer password...that is really becoming annoying after. That happened since I upgraded to mountain lion. How can I stop the computer from asking me that?

    If you are printing via a Windows shared printer and it is the Windows user account that you are being prompted for then you can save this in the Keychain, as shown below.

  • Hi everyone ,my iphones been stolen how can i stop the rheif from using it ?

    Hi my iphones been stolen how can i stop the theif from using it

    Hi Sydney plumbers,
    If you have recently had an iPhone stolen or lost, you may find the following article helpful:
    Apple Support: What to do if your iOS device is lost or stolen
    http://support.apple.com/kb/ht5668
    Regards,
    - Brenden

  • PSE remains active in background after exit. How can I stop the program completely?

    PSE remains active in background after exit. How can I stop the program completely?
    Is there any command line option to force PSE to stop completely after exiting the GUI?
    Opening the Windows Task Manager and killing the PSE process is not a solution!
    (Context: I want to start PhotoshopElementsEditor.exe from another program with an image filename as command line argument. This other program waits in background until PhotoshopElementsEditor.exe has finished and pops up again after that. Since PhotoshopElementsEditor.exe continues to run silently in background, the other program will never come back.)

    Hi - having the same problem with PSE process not ending on exit. Have you had any luck in resolving the issue?
    Any advice would be appreciated. TIA

  • How can I stop the screen from rotating on my iPod touch?

    My son is blind and has an ipod5 using the voice over feature. Everytime he moves it says landscape bc of the screen rotating. How can I stop the screen from rotating on him?

    To lock the screen in portrait orientation, swipe up from the bottom edge of the screen to open
    Control Center, then tap  the icon with an arrowed circle with a padlock inside
    page 20 of
    ios 7.0 ipod touch Manual

  • How can I stop the ringer from  showing up on the screen?

    How can I stop the ringer from  showing up on the screen?

    Use VMware Fusion? But seriously, Fusion does what you want. It just puts a mini VM control menu at the top when running full screen (and that's configurable, too), so the main menu bar doesn't appear at all. Which means that it's up to Parallels to handle this. Are you running Parallels 7, which is designed for Lion? If you are and Parallels still doesn't offer something similar, you need to contact Parallels.

  • In Lion, running on an i MAC (late 2006), how can I stop certain programs from automatically starting up when I start my MAC?

    In Lion, running on an I MAC, (late 2006), how can I stop certain programs (iTunes, Word) from automatically starting up when I start the computer?

    Any application that is open when you shut down will re-open when you restart unless you deselect this when shutting down/restarting:
    Also check System Preferences>Users & Groups>Login items tab and make sure there's nothing listed there that you don't want launched.

  • When I navigate to a new page, an additonal page (with a notice that Firefox is blocking access to the page) pops up. How can I stop the page from poping up?

    How do I stop the pop up screens from popping up? I just want the screen I ask for to open

    What is the wording of the message? Could you post a screen shot showing what it looks like? This article has tips on how to do that: [[How do I create a screenshot of my problem?]]
    Also, does the add-on TopArcadeHits sound familiar? You might want to try disabling it here:
    orange Firefox button (or Tools menu) > Add-ons > Extensions category
    Then restart Firefox (usually there is a handy link for this after disabling).

  • Since the last update my iCloud on my tablet is stuck in update will not let me sign out of it or chande anything  how can I stop the upgrade from running. I've tried everything nothing is working.

    My Apple iPad is stuck on the update in iCloud will not let me sign out of it or do anything in icloud. How can I get it to stop running. I have tried everything that I have looked up online and nothing works.  Every time I put in my apple ID it disables me. Ugg I am frustrated!

    Have just seen the answer to this in a another thread.
    Gilly

  • In Address Book how can I stop the cursor from wandering while editing a page?

    At times when I am editing a page in Address Book, the cursor wanders, so the text I am typing shows up in the wrong place. Often it deletes exist text. Why does this happen? How can I prevent it?

    Does this only happen in the Address Book or does it do this all the time and causes only issues in the Address Book?

  • HT1386 How can you stop the iPod from syncing photos ot it?  It takes up too much space!!!!!

    I just got an iPod and am setting things up, but I don't want it to sync my photos from my computer to the iPod as it takes up too much space.  How do I stop it from syncing the photos?

    See here: iOS and iPod: Syncing photos using iTunes
    B-rock

  • How can I STOP the TABS from Automaticly Expanding to the right?

    I don't like several new features.
    1) It is extremely difficult to tell which TAB belongs to the page I'm viewing. This causes me to constantly close the Wrong Page.
    2) When I do close a Tab, the remaining Tabs expand to fill the "Tab Bar" leaving No Blank Space.

    Hi,
    You can try a different theme for Firefox that provides a greater contrast between the active and inactive tabs: https://addons.mozilla.org/en-US/firefox/themes/
    Please note that some of the themes have a thinner tab bar and may diminish the height of the tab bar.
    or
    You can try the add-on [https://addons.mozilla.org/en-US/firefox/addon/colorfultabs/ ColorfulTabs] without changing the theme. It has an option to [https://www.binaryturf.com/free-software/colorfultabs-for-firefox/colorfultabs-documentation-and-help/#3 fade the inactive tabs]. Please note that ColorfulTabs may have issues when used with other Firefox themes.
    You can prevent filling the tab bar to an extent by using the '''Pin as App Tab''' feature. Right-click on a tab and choose '''Pin as App Tab'''. To unpin, right-click on the pinned tab and choose '''Unpin Tab'''.

Maybe you are looking for

  • What do I need to connect to the internet

    I have a mac book OSX 105.3 Leopard, which i purchased in the USA. Since arrivng in the Uk I have been ubable to connect to the internet. I was under the impression that once connected to a modem I would have the interenet. I tried connecting it to t

  • How many computers can I install my Creative Cloud apps on? May 5, 2012 5:57 AM -- Cloud Busted!!!!

    Ok so i was just about to sign up for the cloud... having big problems with the Application Manager not being able to connect to the Interent (???) and re-directed to Customer Service. S aw this question about how many machines one can install on...

  • Can i install flash drive in mid-2009 macbook pro

    I want to increase the storage on my MacBook pro - mid-2009. I use Final Cut so there are demands. Must I stay with a spinning drive or can I install a large flash drive? I big can I go? 2.26 ghz, 8 gigs ram, running latest Mountain Lion (10.8.2) Tha

  • Where are the settings for the "open" command, located at /usr/bin/open?

    I have Windows XP installed on a partition on my Macbook and I use Parallels to access some of the Windows applications. When I am in Mac OS X, and I don't even have a virtual machine running, if I enter the following command in the terminal, I get s

  • CU5 to CU6 upgrade error

    Hello, Upgrading from CU5 to CU6 I ran into this error during the installation. Has anyone seen this before or knows a way round it: Error: The following error was generated when "$error.Clear(); $name = [Microsoft.Exchange.Management.RecipientTasks.