Shell Kodları Ve Python
Shell scriptleri hem kendi başlarına çalıştırabilir hem de diğer programlama dilleriyle beraber kullanabiliriz. Biz python programlama diliyle beraber kullanacağız. Aşağıdaki örnekte kernel ring buffer mesajlarını okuyabilir ya da bulunduğumuz dizindeki bir dosyayı açtırabiliriz. #!/usr/bin/python3 import subprocess import shlex # Bir string dizisini ayırmak için kullandık. class A : def __init__ ( self ): pass def runss ( self ): p1 = subprocess.Popen([ "dmesg -H --level=err,warn" ], shell= True ) output = p1.communicate()[0] def get_iki ( self ): ss = shlex.split( "if [ -f '${iki}' ]; then echo $?; else echo $?; fi" ) exit_status = subprocess.Popen(ss, shell= True ) try : if exit_status == 1 : raise else : subprocess.Popen([ "pluma iki.sh" ], shell= True ) exce...