Forum Discussion

Sebastian_Maniak's avatar
Apr 16, 2015

python f5 sys.argv

Building a python script to enable and disable pool members. I have everything already working great, but i want to pass sys.argv.

 

example i want to issue this command

 

command.py 192.168.1.245 admin admin pool 12.12.12.1 90

 

and want to use these system variables for my script. I am having trouble with sys.argv.

 

If anyone has an example, it would be awesome.

 

a = sys.argv[1:] b = bigsuds.BIGIP( hostname = a[0], username = a[1], password = a[2], pool = a[3], member = a[4], port = a[5], )

 

2 Replies

  • Can you post the error you're receiving? One obvious error you have is the use of comma "," after "a[5]"

     

  • I solved it.

     

    import sys import bigsuds import time

     

    Insert the management IP address and username and password here

    b = bigsuds.BIGIP(hostname = sys.argv[1], username = sys.argv[2], password = sys.argv[3], ) pl = b.LocalLB.Pool

     

    pool = sys.argv[4] member = sys.argv[5] port = sys.argv[6]