I have a defined some variables in a configuration file and I want to use those variables in a python script. For example, I have the following variables in a configuration file.
Now I want to execute those variables whenever the configuration file is being called from python script and print the value of CONN variable using the python script.
I am new to python and appreciate if you could help me fix the following script I wrote.
Using Python 2.7 on Ubuntu 16.04 (Xenial) - What is your system?
Does this help?
As you can see I am using the Python CLI - it's so much easier for testing snippets of code. Note the use of the help function - it shows the equivalent of a man page of Python classes and their methods. I don't know what you were trying to achieve with
but I hope the above helps you with achieving that.
A quick look at the statements I typed in: parser.sections() lists the section of the ini file. parser.items('test_ini') lists the section test_ini as a list of tuples; each tuple a name/value pair. ptfm_dgnst = dict(parser.items('ptfm_dgnst')) creates a dictionary (simplistically Python's hash table) so you can now access the values through their names. conn_str = ptfm_dgnst['conn'] does what I think you were trying to do with the conn_str = os.system() statement.
I hope this helps.
Andrew
Last edited by apmcd47; 06-28-2017 at 12:03 PM..
Reason: Typo! con.system instead of os.system
I am working on Python 2.6.9 (unknown, Aug 5 2016, 11:15:31)
Basically I want to execute the following statements in sequence. It can be done inside the python code but I prefer to have these values defined on the pltfm.ini file and then let python execute these statements and store the output in CONN variable.
I know how to handle this in ksh or bash but I am new to Python so I am looking for assistance here. Thank you
Look at using the following:
Not checked. You will need to read up on shlex and subprocess to get them to work as you would expect. Note that the "proper" way of making system calls in Python is now through the use of subprocess.
Have fun with that
Andrew
Last edited by apmcd47; 06-28-2017 at 12:47 PM..
Reason: Typos. Always typos :)
Hi all,
I am trying to run below python code for connecting remote windows machine from unix to run an python file exist on that remote windows machine..
Below is the code I am trying:
#!/usr/bin/env python
import wmi
c = wmi.WMI("xxxxx", user="xxxx", password="xxxxxxx")... (1 Reply)
I have bash shell script which is internally calling python script.I would like to know how long python is taking to execute.I am not allowed to do changes in python script.Please note i need to know execution time of python script which is getting executed inside shell .I need to store execution... (2 Replies)
I have another basic Pythonic question that I cant seem to figure out. Here we go. So what I am trying to accomplish is simply using a second variable in my "scanjob" variable adding "api_tok". I am using a product that needs an api_token for every call so I just want to persistently add "api_tok"... (0 Replies)
Hi All,
i have a requirement where i have to run a script with at least 25 arguements and position of arguements can also change. the unapropriate way is like below. can we achieve this in more good and precise way??
#!/bin/ksh
##script is sample.ksh
age=$1
gender=$2
class=$3
.
.
.... (3 Replies)
experts, i wrote a python script to do a certain job, i tried it and it is working fine, i want this script to be executed automatically after a ksh script, the problem is when i execute the ksh script my python script runes perfectly after the ksh script as I have include it at the end of the ksh... (1 Reply)
I have a shell script main.sh which inturn call the python script ofdm.py, I want to pass two variables from shell script to python script for its execution. How do i achieve this ?????
Eg:
main.sh
a=3 b=3;
c= a+b
exec python ofdm.py
ofdm.py
d=c+a
Thanks in Anticipation (4 Replies)
Hello again,
You guys might remember me from the "Apache problems" thread. And because this forum is the only one that actually helped me out after months of problems I was hoping you could help me with something related.
Now if you remember the final code that we made for creating an account... (0 Replies)
Hi
I need to run a shell script from a TCL script,the shell script in trun will run a python script
1.Tcl script
set filename "./GopiRun.sh"
2.GopiRun.sh
python ./psi.py $MYSB/test_scripts/delivery/gpy1.py
3.I have my gpy1.py script.
Here the problem i am facing is on running... (0 Replies)