User Profile

Collapse

Profile Sidebar

Collapse
ennoil
ennoil
Last Activity: Jun 8 '10, 03:49 PM
Joined: May 28 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • ennoil
    started a topic pexpect output

    pexpect output

    I have a script that uses pexpect to ssh to a list of servers and will run a user specified command on each server. I have tried to use pexpect logging to output the results of each command to a file so the user can see the output (of commands such as uptime and ntpdate). The remote servers are both Solaris and Red Hat. For some reason, not all output is captured in the file.
    Here is my code:

    Some code unnecessary and snipped...
    See more | Go to post

  • ennoil
    replied to Check if a tuple contains a string
    Part of the problem is that not all of the 4 items in EnvList need to exist.
    For example, if I want to pick just the Solaris servers out of the ServerList then EnvList will only contain
    ['Solaris']
    EnvList is created through a series of menus from which the user will pick only then EnvList items that they need.
    See more | Go to post

    Leave a comment:


  • ennoil
    started a topic Check if a tuple contains a string

    Check if a tuple contains a string

    I have a tuple of a tuple (ServerList) that contains the following:

    <host1>,DEV,Inf ormatica,Red_Ha t,64
    <host2>,PROD,In formatica,Red_H at,64
    <host3>,PROD,In formatica,Red_H at,64
    <host4>,QA,Info rmatica,Red_Hat ,64
    <host5>,PROD,Ti bco,Solaris,
    <host6>,TEST,Ti bco,Solaris,

    I have a list (EnvList) that could contain the following:

    ['PROD','Informa tica','Red_Hat' ,'64']...
    See more | Go to post

  • ennoil
    replied to Validate user input
    That does look better than my code but still errors if the user does not enter a number (or, more importantly for this) just hits enter.
    See more | Go to post

    Leave a comment:


  • ennoil
    started a topic Validate user input

    Validate user input

    I am requesting user input from a menu a script. The input I am requesting needs to be an integer. Is it possible to validate that the user actually entered an integer and not a string or just hit enter? Everything I have tried will give me
    "File "<string>", line 0, in ?
    NameError: name 'd' is not defined
    The code I have looks like this:

    Code:
    def init_menu():
      print '''
      0) Exit
    ...
    See more | Go to post
    Last edited by ennoil; Jun 1 '10, 04:07 PM. Reason: Corrected typo...

  • In vi, at least, this will replace a number that is the first character on a line (lines 7-11 only) with the string "Toughie". The 'c' at the end will ask the user for confirmation.
    See more | Go to post

    Leave a comment:


  • To do what you want, as written, is impossible. To change a user's primary group requires them to log out and log back in again. You will need to, as suggested above, use setGID to allow users to act on the directory as the primary group.
    See more | Go to post

    Leave a comment:


  • ennoil
    replied to Unix Record Extract by Column Value
    You can use the cut (-b) command and specify what position in the string that you want to look at...From there you can use an if statement:

    Code:
    for i in `cat <file>`
    do
      section=`echo ${i} | cut -b 87-89`
      if [[ ${section} == "003" -o ${section} == "004"
      then
        echo ${section}
      fi
    done
    Just for a start...
    See more | Go to post

    Leave a comment:


  • ennoil
    replied to Using data from csv file several times
    Sorry, forgot to declare data before...
    data = []
    (Is that declaring it as a dictionary? Is there a table that shows what each are ([], {}...)
    John
    See more | Go to post
    Last edited by ennoil; May 28 '10, 07:22 PM. Reason: I am never happy with the first one...

    Leave a comment:


  • ennoil
    replied to Using data from csv file several times
    Would something like:

    Code:
    import csv
    
    f = open(".servers.txt", "r")
    reader = csv.reader(f)
    for row in reader:
      data.append(row[0]: [row[1], row[2], row[3], row[4])
    f.close
    work?
    Thanks
    See more | Go to post

    Leave a comment:


  • ennoil
    started a topic Using data from csv file several times

    Using data from csv file several times

    I am new to Python. I am trying to port a BASH script I wrote to Python so I can learn the language.
    I have a csv file with 5 columns. The first column is a host name. Second through 5th have different attributes of the host (environment, use, OS, architecture). I want to allow the user to pick one type from each column and output the hostnames that match the users request (i.e. list all hostnames that are Oracle servers in Production running...
    See more | Go to post
    Last edited by ennoil; May 28 '10, 05:47 PM. Reason: Added PS...
No activity results to display
Show More
Working...