Oct-21-2018, 03:59 AM
(This post was last modified: Oct-21-2018, 03:59 AM by alinaveed786.)
Yes. It is now working. The issue was with chdir outside for loop
How can I combine both for loops into one so that I should have only one list variable instead of two(patch1 and patch2)? The reason I used two list variables is because patches of patch1 are inside /u02/28317232 and patches of patch2 are inside /u02/ after unzipping
How can I combine both for loops into one so that I should have only one list variable instead of two(patch1 and patch2)? The reason I used two list variables is because patches of patch1 are inside /u02/28317232 and patches of patch2 are inside /u02/ after unzipping
#!/usr/local/bin/python3.6 import subprocess from plumbum import local, cmd patch1 = [27923320,27547329] patch2 = [21171382,21463894,18961555,28432129] 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() print('Applying PSU patches') for j in patch1: if osTyp == 'Linux': local.cwd.chdir('/u02/') cmd.unzip('-o', "/u02/p28317232*.zip".format(j)) local.cwd.chdir('/u02/28317232/{}'.format(j)) subprocess.run('opatch apply -silent', shell=True) print('Patch',j, 'applied') elif osTyp == 'SunOs': cmd.unzip("p{}_121020_Solaris-x86-64.zip".format(j)) else: print("!!\n!! unable to determine OS type !!\n!!") print('Applying one-off patches') for i in patch2: if osTyp == 'Linux': local.cwd.chdir('/u02/') cmd.unzip('-o', "/u02/p{}_*.zip".format(i)) local.cwd.chdir('/u02/{}'.format(i)) subprocess.run('opatch apply -silent', shell=True) print('Patch',i, 'applied') elif osTyp == 'SunOs': cmd.unzip("p{}_121020_Solaris-x86-64.zip".format(i)) else: print("!!\n!! unable to determine OS type !!\n!!")Contents of /u02
[oracle@cdb1 u02]$ pwd /u02 [oracle@cdb1 u02]$ ls -ltr total 789832 drwxrwxr-x. 4 oracle oinstall 4096 Aug 6 2015 21463894 drwxrwxr-x. 4 oracle oinstall 4096 Apr 25 15:18 18961555 drwxrwxr-x. 4 oracle oinstall 4096 Jun 27 10:48 21171382 drwxrwxr-x. 4 oracle oinstall 4096 Aug 7 18:32 28432129 -rw-rw-r--. 1 oracle oinstall 4596 Aug 8 07:01 PatchSearch.xml -rwxrwx---. 1 oracle oinstall 30301 Oct 17 20:59 p18961555_12102180417_Linux-x86-64.zip -rwxrwx---. 1 oracle oinstall 212238 Oct 17 21:00 p28432129_12102180717_Linux-x86-64.zip -rwxrwx---. 1 oracle oinstall 807969208 Oct 17 21:01 p28317232_121020_Linux-x86-64.zip -rwxrwx---. 1 oracle oinstall 451814 Oct 17 21:01 p21171382_12102180417_Generic.zip -rwxrwx---. 1 oracle oinstall 73502 Oct 17 21:10 p21463894_121020_Linux-x86-64.zip drwxr-xr-x. 10 oracle oinstall 4096 Oct 18 08:52 pycharm-community-2018.2.4 drwxr-xr-x. 3 oracle oinstall 4096 Oct 18 09:23 scripts drwxr-xr-x. 4 oracle oinstall 4096 Oct 21 09:11 28317232 [oracle@cdb1 u02]$ [oracle@cdb1 u02]$ cd 28317232 [oracle@cdb1 28317232]$ pwd /u02/28317232 [oracle@cdb1 28317232]$ ls -ltr total 40 -rw-r--r--. 1 oracle oinstall 21 Jul 10 18:59 README.txt -rw-rw-r--. 1 oracle oinstall 24710 Jul 12 07:27 README.html drwxr-xr-x. 18 oracle oinstall 4096 Oct 21 09:11 27547329 drwxr-xr-x. 4 oracle oinstall 4096 Oct 21 09:11 27923320