Need help with emcli in OEM 12c, maybe use shell script or python and run a series of emcli commands.

I have to populate the target properties of every target in OEM 12c.
I am trying a few to see if this will work.
When I run this, i get 82 rows.

select 'emcli set_target_property_value -property_records="'||a.TARGET_NAME||':'||a.TARGET_TYPE||':LifeCycle Status:'||b.property_value||'"'
from mgmt$target a,
(select target_name host,property_value from mgmt$target_properties
where target_type='host' and property_name='orcl_gtp_lifecycle_status') b
where a.host_name=b.host
and a.host_name  like '%lods07%';

I have attached the file, please take a look.

On the server after I log into emcli and log in as sysman, I can run each line follows:

oms_home@loem301dz:/odb/oem01/orabin/admin>emcli set_target_property_value -property_records="testdb87.rnd.pncint.net:rac_database:LifeCycle Status:Test"
Properties updated successfully

How do i create either a shell script or python script to either execute each line as a script or write a python script to do so?
Rao_SAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gerwin Jansen, EE MVETopic Advisor Commented:
Hi, what you can do is create a shell script of the first part that sends the output to a secondary file. Then as a next step call that secondary file from the shell script.

Something like:

sqlplus -s user/password@database << EOF
set head off
set feedback off
set head off
set pages 0
spool secondary_script
select 'emcli set_target_property_value -property_records="'||a.TARGET_NAME||':'||a.TARGET_TYPE||':LifeCycle Status:'||b.property_value||'"'
from mgmt$target a,
(select target_name host,property_value from mgmt$target_properties
where target_type='host' and property_name='orcl_gtp_lifecycle_status') b
where a.host_name=b.host
and a.host_name  like '%lods07%';
spool off
EOF
sh ./secondary_script

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rao_SAuthor Commented:
Will look at it in detail later..
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.