Oct-20-2018, 03:14 PM
(This post was last modified: Oct-20-2018, 03:14 PM by alinaveed786.)
thanks for the response, helped me a lot. How can I pass list "patch" value as variable to below code?
#!/usr/local/bin/python3.6 import subprocess from plumbum import local, cmd patch = [27923320, 27547329, 21463894] ORACLE_HOME = local.env['ORACLE_HOME'] path = local.env['PATH'] local.env['PATH'] = "{ohome}/bin:{ohome}/OPatch:{path}".format(ohome=ORACLE_HOME, path=local.env['PATH']) osTyp = cmd.uname('-s').strip() for i in patch: if osTyp == 'Linux': cmd.unzip('-o',"/u03/p[i]_121020_Linux-x86-64.zip") local.cwd.chdir('/u03/[i]') subprocess.run('pwd', shell=True) subprocess.run('opatch apply -silent', shell=True) print('Patch applied') elif osTyp == 'SunOs': cmd.unzip("p[i]_121020_Solaris-x86-64.zip") else: print("!!\n!! unable to determine OS type !!\n!!")Error:
cmd.unzip('-o',"/u03/p[i]_121020_Linux-x86-64.zip") File "/usr/local/lib/python3.6/site-packages/plumbum/commands/base.py", line 103, in __call__ return self.run(args, **kwargs)[1] File "/usr/local/lib/python3.6/site-packages/plumbum/commands/base.py", line 240, in run return p.run() File "/usr/local/lib/python3.6/site-packages/plumbum/commands/base.py", line 201, in runner return run_proc(p, retcode, timeout) File "/usr/local/lib/python3.6/site-packages/plumbum/commands/processes.py", line 232, in run_proc return _check_process(proc, retcode, timeout, stdout, stderr) File "/usr/local/lib/python3.6/site-packages/plumbum/commands/processes.py", line 23, in _check_process proc.verify(retcode, timeout, stdout, stderr) File "/usr/local/lib/python3.6/site-packages/plumbum/machines/base.py", line 26, in verify stderr) plumbum.commands.processes.ProcessExecutionError: Command line: ['/u01/app/oracle/product/12.1.0.2/db_1/bin/unzip', '-o', '/u03/p[i]_121020_Linux-x86-64.zip'] Exit code: 9 Stderr: | unzip: cannot find or open /u03/p[i]_121020_Linux-x86-64.zip, /u03/p[i]_121020_Linux-x86-64.zip.zip or /u03/p[i]_121020_Linux-x86-64.zip.ZIP. | | No zipfiles found. Process finished with exit code 1