Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 08-05-2015, 03:46 AM
john.salcedo john.salcedo is offline
Registered User
 
Join Date: Aug 2015
Posts: 1
Python scripting help (Log-in and retrieve output from multiple devices)

I have 0 experience with regards to scripting, I have only done fundamental research on what language I have to study first. Python looks promising, it is beginner friendly, has a variety of applications, etc. I've looked at the sample Python scripts available at the website but I'm afraid non fits the exact goal I'm trying to achieve. I think I just need a sample working script I could use and whose function I understand to get my feet wet in scripting so if anybody could please provide a working best-practice Python script for the following goal:

Given:
x = (x1, x2, ... , xn)
y = (y1, y2, ... , yn)

Goal:
1. Login to each device via ssh for each element in set x
2. Retrieve output from each device using each element in set y
3. Filter the output using this condition:
Parse the output of y1, look for string 'a', then get b characters that appear after string 'a'. e.g.
'if b=5, the command will get 12345 from the output of y1
hostname>y1
xxxxxxxxxxx
xxxxxxxxxxx
xxxa12345x
xxxxxxxxxxx
4. Save this file using the following wildcard format: <hostname><date>
Please show how to save to a file using both simple text file and to csv file formats.

when using the csv format, how can it appear to be:
x1, y1output, y2output, ynoutput
x2, y1output, y2output, ynoutput
xn, y1output, y2output, ynoutput

Thanks!!!
Reply With Quote
  #2  
Old 08-05-2015, 09:55 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi john.salcedo,

Thanks for the post. Here is an example that you could use to begin your journey:
https://forums.vandyke.com/showthrea...7294#post37294
The VBScript version is better structured, but you could also adapt the Python version to meet your specific needs.

Do these examples help you get started?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
Reply

Tags
multiple session , python , retrieve output , save to a file


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 04:54 AM.