1.리눅스 vim에서 출력후에 빈줄도 출력하고싶은데 방법이 있을까요? 10줄이 있으면 root,hostname이 UID라면 나머지 8줄은 \n으로 출력하고 싶습니다.
2.리눅스 ps -ef중복아닌 것을 하다보니 UID 와 같이 목록?이 출력이 됩니다. 이것을 빼는 방법이 있나요?
awk를 이용해서 뽑아내고있는데 맞는방법일까요
답변 먹튀 하셨네요. https://kldp.org/node/161562
포럼은 삭제가 안되는 줄 모르고 글을 남겼는데, 해결을 해서 제 딴에는 글을 지워놓으면 댓글을 안달아 주실줄 알았습니다. 친절하게 답변해주셨네요.. 너무너무 감사합니다. 앞으로 이런 실수 없도록 주의하겠습니다. 감사합니다.
질문자께서 원하는바를 정확히 모르겠지만, 일단 추측으로 코드를 작성해봤습니다.
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # ps -ef 에서 '?' 없는 줄만 출력 import subprocess cmd_1 = "rm -f /tmp/ps.txt" cmd_2 = "ps -ef > /tmp/ps.txt" subprocess.call(cmd_1, shell=True) subprocess.call(cmd_2, shell=True) f = open("/tmp/ps.txt", "r") lines = f.readlines() ff = filter(lambda x: '?' not in x, lines) for v in ff: print(v.strip()) f.close() """ 우분투 18.04, 파이썬 3.6.7 (bionic)soyeomul@localhost:~/test$ ./3.py UID PID PPID C STIME TTY TIME CMD root 370 334 0 09:51 pts/1 00:00:00 /sbin/agetty - 9600 xterm root 374 334 0 09:51 pts/2 00:00:00 /sbin/agetty - 9600 xterm root 379 334 0 09:51 pts/3 00:00:00 /sbin/agetty - 9600 xterm soyeomul 3531 1346 0 09:52 pts/0 00:00:00 /bin/bash /usr/bin/crosh soyeomul 3680 3531 0 09:52 pts/0 00:00:00 /bin/bash /usr/bin/crosh soyeomul 3681 3680 0 09:52 pts/0 00:00:00 /bin/bash -l root 19621 3681 0 12:29 pts/0 00:00:00 sudo LD_LIBRARY_PATH=/usr/local/lib startgnome root 19626 19621 0 12:29 pts/0 00:00:00 sh -e /usr/local/bin/enter-chroot -t gnome exec startgnome root 19926 19626 0 12:29 pts/0 00:00:00 su -s /bin/sh -c export SHELL='/bin/bash';'exec' 'startgnome' - soyeomul soyeomul 23418 23412 0 12:43 pts/4 00:00:00 bash soyeomul 29413 23418 0 13:20 pts/4 00:00:00 python3 ./3.py soyeomul 29418 29413 0 13:20 pts/4 00:00:00 /bin/sh -c ps -ef > /tmp/ps.txt soyeomul 29419 29418 0 13:20 pts/4 00:00:00 ps -ef (bionic)soyeomul@localhost:~/test$ """
-- ^고맙습니다 감사합니다_^))//
import subprocess p = subprocess.Popen(["ps", "-ef"], stdout=subprocess.PIPE, text=True) for proc in p.stdout: if '?' not in proc: print(proc.strip())
간결한 코드 stdout 기억할께요 감사합니다^^^
Traceback (most recent call last): File "./33.py", line 8, in <module> p = subprocess.Popen(["ps", "-ef"], stdout=subprocess.PIPE, text=True) TypeError: __init__() got an unexpected keyword argument 'text'
Changed in version 3.7: Added the text parameter, as a more understandable alias of universal_newlines. Added the capture_output parameter.
https://docs.python.org/3/library/subprocess.html
정확한 정보 주셔서 감사드립니다. 우분투에서 3.7 파이썬 설치후에 코드도 좀 보완해서 테스트해봤습니다.
#!/usr/bin/env python3.7 # -*- coding: utf-8 -*- # 우분투 18.04 에서 파이썬 3.7 까는법 # sudo apt-get update # sudo apt-get install python3.7 # 실행파일위치: /usr/bin/python3.7 import subprocess import sys cpv = float((sys.version)[0:3]) # 현재 파이썬 판번호 "3.x" spv = float("3.7") # 기준 파이썬 판번호 "3.7" if cpv >= spv: p = subprocess.Popen(["ps", "-ef"], stdout=subprocess.PIPE, text=True) else: print("Must be using Python 3.7 (or the above)") exit(1) for proc in p.stdout: if '?' not in proc: print(proc.strip()) # 편집: Emacs 26.1 (Ubuntu 18.04) # 마지막 갱신: 2019년 5월 13일 """ 테스트 결과: 우분투 18.04, 파이썬 3.7.1 (bionic)soyeomul@localhost:~/test$ ./333.py UID PID PPID C STIME TTY TIME CMD root 370 334 0 5월11 pts/1 00:00:00 /sbin/agetty - 9600 xterm root 374 334 0 5월11 pts/2 00:00:00 /sbin/agetty - 9600 xterm root 379 334 0 5월11 pts/3 00:00:00 /sbin/agetty - 9600 xterm soyeomul 3531 1346 0 5월11 pts/0 00:00:00 /bin/bash /usr/bin/crosh soyeomul 3680 3531 0 5월11 pts/0 00:00:00 /bin/bash /usr/bin/crosh soyeomul 3681 3680 0 5월11 pts/0 00:00:00 /bin/bash -l soyeomul 6512 29800 0 21:56 pts/4 00:00:00 python3.7 ./333.py soyeomul 6513 6512 0 21:56 pts/4 00:00:00 ps -ef root 24831 3681 0 20:50 pts/0 00:00:00 sudo LD_LIBRARY_PATH=/usr/local/lib startgnome root 24836 24831 0 20:50 pts/0 00:00:00 sh -e /usr/local/bin/enter-chroot -t gnome exec startgnome root 25137 24836 0 20:50 pts/0 00:00:00 su -s /bin/sh -c export SHELL='/bin/bash';'exec' 'startgnome' - soyeomul soyeomul 29800 29794 0 21:11 pts/4 00:00:00 bash (bionic)soyeomul@localhost:~/test$ """
참고문헌: https://docs.python.org/3/library/sys.html#sys.hexversion
정보 공유차원에서 댓글로 남깁니다. 코드 실험결과는 아래서 확인할 수 있어요~https://gitlab.com/soyeomul/test/raw/2dbfddd688c5b41b8f01ca3db769e0add68d66e9/333.py
꾸벅,,,
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # UID/PID/CMD 열만 출력하기 `ps -ef' import subprocess cmd_1 = "rm -f /tmp/ps.txt" cmd_2 = "ps -ef > /tmp/ps.txt" subprocess.call(cmd_1, shell=True) subprocess.call(cmd_2, shell=True) f = open("/tmp/ps.txt", "r") lines = f.readlines() v0 = [] for x in lines: v0.append(x.split()[0]) UID = v0 v1 = [] for x in lines: v1.append(x.split()[1]) PID = v1 v7 = [] for x in lines: v7.append(x.split()[7]) CMD = v7 for x,y,z in zip(UID,PID,CMD): print(f'{x:10} {y:7} {z:10}') f.close() """ 테스트결과: 우분투 18.04, 파이썬 3.6.7 (bionic)soyeomul@localhost:~/test$ ./4.py UID PID CMD root 1 /sbin/init root 2 [kthreadd] root 3 [ksoftirqd/0] root 5 [kworker/0:0H] root 7 [rcu_preempt] root 8 [rcu_sched] root 9 [rcu_bh] root 10 [migration/0] root 11 [watchdog/0] root 12 [watchdog/1] root 13 [migration/1] root 14 [ksoftirqd/1] root 16 [kworker/1:0H] root 17 [watchdog/2] root 18 [migration/2] root 19 [ksoftirqd/2] root 21 [kworker/2:0H] root 22 [watchdog/3] root 23 [migration/3] root 24 [ksoftirqd/3] root 26 [kworker/3:0H] root 27 [khelper] root 28 [kdevtmpfs] root 29 [netns] root 30 [perf] root 31 [khungtaskd] root 32 [writeback] root 33 [khugepaged] root 34 [crypto] root 35 [bioset] root 36 [kblockd] root 37 [ata_sff] root 38 [devfreq_wq] root 39 [cfinteractive] root 40 [kvm_arch_timer] root 42 [kvm-irqfd-clean] root 65 [kswapd0] root 66 [fsnotify_mark] root 67 [ecryptfs-kthrea] root 86 [cmdq_auto_relea] root 87 [cmdq_task] root 88 [irq/239-hdmi root 89 [irq/25-mt6397-p] root 90 [spi32766] root 96 [irq/14-chromeos] root 102 [kpsmoused] root 123 [vpu_wdt] root 124 [mtk-vcodec-enc] root 125 [irq/102-ekth350] root 127 [irq/131-ekth300] root 128 [cros_usb_pd_log] root 130 [dm_bufio_cache] root 131 [irq/15-11240000] root 133 [mmcqd/0] root 134 [mmcqd/0boot0] root 135 [mmcqd/0boot1] root 136 [mmcqd/0rpmb] root 137 [system] root 138 [carveout] root 139 [chunk] root 140 [binder] root 141 [irq/17-rt5645] root 142 [ipv6_addrconf] root 155 [hwrng] root 156 [pvr_timer] root 157 [pvr_defer_free] root 158 [pvr_device_wdg] root 159 [pvr_cacheop] root 160 [deferwq] root 161 [irq/50-gpio-dis] root 162 [mtk-vcodec-dec] root 163 [mtk-mdp] root 164 [mdp_wdt_wq] root 165 [irq/249-mtk-svs] root 166 [pvr_fence_sync_] root 171 [kdmflush] root 172 [bioset] root 173 [kverityd] root 174 [bioset] root 175 [kworker/2:1H] root 176 [ext4-rsv-conver] root 177 [kworker/3:1H] root 182 [kworker/0:1H] root 183 [kworker/1:1H] root 207 udevd root 218 [jbd2/mmcblk0p1-] root 219 [ext4-rsv-conver] root 221 [jbd2/mmcblk0p8-] root 222 [ext4-rsv-conver] root 334 frecon root 339 [loop0] root 341 [kdmflush] root 349 [bioset] root 350 [kcryptd_io] root 351 [kcryptd] root 352 [bioset] root 356 [jbd2/dm-1-8] root 357 [ext4-rsv-conver] root 360 [pvr_workqueue] root 361 [pvr_workqueue] root 362 [pvr_workqueue] root 365 [frecon] root 370 /sbin/agetty root 374 /sbin/agetty root 379 /sbin/agetty 603 489 /usr/bin/arc_camera_service root 517 [loop1] 202 523 /usr/lib/systemd/systemd-journald root 544 [loop2] root 547 [loop3] 201 580 dbus-daemon 202 629 /usr/sbin/rsyslogd 219 737 /usr/sbin/wpa_supplicant root 886 [irq/282-cros-ec] 228 1235 /usr/bin/powerd 229 1291 /usr/sbin/daisydog root 1298 session_manager root 1342 /sbin/debugd soyeomul 1346 /opt/google/chrome/chrome 207 1354 tcsd 223 1363 chapsd root 1447 cryptohomed root 1492 /usr/bin/shill root 1494 [metrics_client] 202 1495 /usr/bin/logger soyeomul 1502 /opt/google/chrome/chrome root 1503 [cfg80211] soyeomul 1532 /opt/google/chrome/nacl_helper_bootstrap soyeomul 1535 /opt/google/chrome/nacl_helper_nonsfi soyeomul 1538 /opt/google/chrome/chrome soyeomul 1557 /opt/google/chrome/chrome soyeomul 1562 /opt/google/chrome/chrome soyeomul 1609 /opt/google/chrome/chrome root 1683 [kworker/u8:4] root 1686 [kworker/u8:7] root 1698 [kworker/0:3] root 1700 [kworker/1:1] root 1743 /bin/sh root 1745 /bin/sh root 1786 /bin/sh root 1810 minijail0 226 1816 /usr/sbin/mtpd 238 1823 avahi-daemon: 241 1825 /usr/sbin/ModemManager 230 1831 /usr/bin/permission_broker 213 1861 /usr/bin/cros-disks 284 1875 /usr/bin/arc-networkd 232 1876 /sbin/minijail0 root 1889 upstart-socket-bridge 232 1901 /usr/sbin/conntrackd root 1904 /usr/bin/arc-networkd 600 1912 /usr/bin/cras 238 1915 avahi-daemon: root 1976 [MWIFIEX_WORK_QU] root 1977 [MWIFIEX_RX_WORK] root 1978 [ksdioirqd/mmc2] root 1979 update_engine root 1996 [btmrvl_main_ser] root 1997 [hci0] root 1998 [hci0] root 2142 /bin/sh root 2255 /bin/sh root 2270 minijail0 root 2274 /sbin/minijail0 root 2283 timberslide root 2284 minijail0 root 2287 minijail0 root 2313 /sbin/minijail0 218 2328 /usr/libexec/bluetooth/bluetoothd 234 2334 /usr/bin/tlsdated root 2349 /usr/bin/anomaly_collector root 2362 [krfcommd] root 2377 /usr/bin/tlsdated 218 2642 /usr/bin/btdispatch 218 2643 /usr/bin/newblued 224 2656 /sbin/dhcpcd root 2735 metrics_daemon root 2738 minijail0 root 2744 /usr/bin/memd soyeomul 2834 /opt/google/chrome/chrome root 3044 sudo root 3049 sh 249 3166 /opt/google/easy_unlock/easy_unlock message+ 3331 dbus-daemon root 3337 /lib/systemd/systemd-logind 304 3349 /opt/google/drive-file-stream/drivefs soyeomul 3376 /opt/google/chrome/chrome root 3381 su soyeomul 3390 /usr/bin/xinit soyeomul 3400 /usr/lib/xorg/Xorg soyeomul 3477 /bin/sh soyeomul 3486 /bin/sh soyeomul 3487 /bin/sh soyeomul 3497 xbindkeys soyeomul 3504 /bin/sh soyeomul 3505 /bin/sh soyeomul 3506 mawk soyeomul 3511 hexdump soyeomul 3512 hexdump soyeomul 3513 hexdump soyeomul 3514 hexdump soyeomul 3515 hexdump soyeomul 3516 hexdump soyeomul 3517 hexdump soyeomul 3518 /opt/google/chrome/chrome soyeomul 3531 /bin/bash soyeomul 3536 /usr/lib/gnome-session/gnome-session-binary soyeomul 3553 dbus-launch soyeomul 3554 /usr/bin/dbus-daemon soyeomul 3589 /usr/bin/dbus-launch soyeomul 3590 /usr/bin/dbus-daemon soyeomul 3599 /usr/bin/ssh-agent soyeomul 3608 /usr/bin/nabi soyeomul 3611 /usr/lib/at-spi2-core/at-spi-bus-launcher soyeomul 3616 /usr/bin/dbus-daemon soyeomul 3622 /usr/lib/at-spi2-core/at-spi2-registryd soyeomul 3662 /usr/bin/gnome-screensaver soyeomul 3667 /usr/lib/gvfs/gvfsd soyeomul 3672 /usr/lib/gvfs/gvfsd-fuse soyeomul 3680 /bin/bash soyeomul 3681 /bin/bash soyeomul 3688 /usr/bin/gnome-keyring-daemon soyeomul 3704 /usr/bin/gnome-shell root 3711 /usr/lib/upower/upowerd soyeomul 3739 /usr/bin/pulseaudio soyeomul 3756 ibus-daemon soyeomul 3760 /usr/lib/ibus/ibus-dconf soyeomul 3763 /usr/lib/ibus/ibus-x11 soyeomul 3766 /usr/lib/ibus/ibus-portal soyeomul 3775 /usr/lib/gnome-shell/gnome-shell-calendar-server soyeomul 3780 /usr/lib/evolution/evolution-source-registry soyeomul 3788 /usr/lib/gnome-online-accounts/goa-daemon soyeomul 3798 /usr/lib/gnome-online-accounts/goa-identity-service root 3803 /usr/lib/accountsservice/accounts-daemon root 3808 /usr/lib/policykit-1/polkitd geoclue 3813 /usr/lib/geoclue-2.0/geoclue root 3817 /usr/lib/aarch64-linux-gnu/boltd soyeomul 3821 /usr/lib/dconf/dconf-service root 3824 /sbin/wpa_supplicant root 3831 /usr/sbin/ModemManager soyeomul 3837 /usr/lib/gvfs/gvfs-udisks2-volume-monitor root 3841 /usr/lib/udisks2/udisksd soyeomul 3865 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor soyeomul 3870 /usr/lib/gvfs/gvfs-goa-volume-monitor soyeomul 3875 /usr/lib/gvfs/gvfs-mtp-volume-monitor soyeomul 3881 /usr/lib/gvfs/gvfs-afc-volume-monitor root 3887 /usr/lib/packagekit/packagekitd soyeomul 3890 /usr/lib/gnome-settings-daemon/gsd-power soyeomul 3893 /usr/lib/gnome-settings-daemon/gsd-print-notifications soyeomul 3894 /usr/lib/gnome-settings-daemon/gsd-rfkill soyeomul 3898 /usr/lib/gnome-settings-daemon/gsd-screensaver-proxy soyeomul 3901 /usr/lib/gnome-settings-daemon/gsd-sharing soyeomul 3912 /usr/lib/gnome-settings-daemon/gsd-smartcard soyeomul 3914 /usr/lib/gnome-settings-daemon/gsd-xsettings soyeomul 3918 /usr/lib/gnome-settings-daemon/gsd-sound soyeomul 3919 /usr/lib/gnome-settings-daemon/gsd-wacom soyeomul 3929 /usr/lib/gnome-settings-daemon/gsd-a11y-settings soyeomul 3930 /usr/lib/gnome-settings-daemon/gsd-clipboard soyeomul 3934 /usr/lib/gnome-settings-daemon/gsd-color soyeomul 3936 /usr/lib/gnome-settings-daemon/gsd-datetime soyeomul 3937 /usr/lib/gnome-settings-daemon/gsd-housekeeping soyeomul 3938 /usr/lib/gnome-settings-daemon/gsd-keyboard soyeomul 3942 /usr/lib/gnome-settings-daemon/gsd-media-keys soyeomul 3943 /usr/lib/gnome-settings-daemon/gsd-mouse soyeomul 3954 /usr/lib/gnome-settings-daemon/gsd-printer colord 3984 /usr/lib/colord/colord root 4009 [kauditd] soyeomul 4017 /usr/lib/gnome-disk-utility/gsd-disk-utility-notify soyeomul 4020 /usr/lib/evolution/evolution-calendar-factory root 4060 /usr/sbin/cron soyeomul 4070 /usr/lib/evolution/evolution-calendar-factory-subprocess soyeomul 4084 /usr/lib/evolution/evolution-addressbook-factory soyeomul 4090 /usr/lib/ibus/ibus-engine-simple soyeomul 4106 /usr/lib/evolution/evolution-addressbook-factory-subprocess soyeomul 4136 /usr/bin/ssh-agent soyeomul 4139 ssh soyeomul 4180 emacs26 soyeomul 4305 /usr/bin/gnome-software soyeomul 4312 update-notifier root 4331 /usr/lib/fwupd/fwupd soyeomul 4605 /usr/lib/deja-dup/deja-dup-monitor soyeomul 4745 /usr/lib/firefox/firefox soyeomul 4804 /usr/lib/firefox/firefox soyeomul 4845 /usr/lib/firefox/firefox soyeomul 4892 /usr/lib/firefox/firefox soyeomul 4958 /opt/google/chrome/chrome root 4985 [kworker/u9:2] soyeomul 5123 /usr/lib/gnome-terminal/gnome-terminal-server soyeomul 5129 bash root 5745 [kworker/3:0] root 5932 [kworker/u9:0] soyeomul 6664 /opt/google/chrome/chrome soyeomul 6676 /opt/google/chrome/nacl_helper_bootstrap root 6686 [kworker/u8:1] root 6881 [kworker/0:0] root 7151 /usr/bin/coreutils root 7155 /usr/bin/coreutils root 7159 /usr/bin/coreutils root 7163 /usr/bin/coreutils root 7365 [kworker/u9:1] soyeomul 7778 sleep soyeomul 7788 sleep root 7792 /usr/bin/coreutils soyeomul 7793 python3 soyeomul 7796 /bin/sh soyeomul 7797 ps soyeomul 19569 /opt/google/chrome/chrome root 19611 [kworker/2:0] root 27848 [kworker/u8:3] root 30420 [kworker/1:0] root 31007 [kworker/u9:3] root 31423 [kworker/3:1] root 32525 [kworker/2:1] (bionic)soyeomul@localhost:~/test$ """
CMD 열이 사실 대게 긴줄도 있습니다. 그래서 코드를 좀 더 보완했씁니다.
...snip... v7 = [] for x in lines: v7.append(x.split()[7:]) # [7] 에서 [7:] 로 변경합니다. CMD = v7 for x,y,z in zip(UID,PID,CMD): print(f'{x:10} {y:7} {" ".join(z)[:43]}') # z 항목을 43자까지만 출력시키도록... ...snip...
# 변경된 코드 테스트 결과입니다. # 우분투 18.04, 파이썬 3.6.7 (bionic)soyeomul@localhost:~/test$ ./4.py UID PID CMD root 1 /sbin/init root 2 [kthreadd] root 3 [ksoftirqd/0] root 5 [kworker/0:0H] root 7 [rcu_preempt] root 8 [rcu_sched] root 9 [rcu_bh] root 10 [migration/0] root 11 [watchdog/0] root 12 [watchdog/1] root 13 [migration/1] root 14 [ksoftirqd/1] root 16 [kworker/1:0H] root 17 [watchdog/2] root 18 [migration/2] root 19 [ksoftirqd/2] root 21 [kworker/2:0H] root 22 [watchdog/3] root 23 [migration/3] root 24 [ksoftirqd/3] root 26 [kworker/3:0H] root 27 [khelper] root 28 [kdevtmpfs] root 29 [netns] root 30 [perf] root 31 [khungtaskd] root 32 [writeback] root 33 [khugepaged] root 34 [crypto] root 35 [bioset] root 36 [kblockd] root 37 [ata_sff] root 38 [devfreq_wq] root 39 [cfinteractive] root 40 [kvm_arch_timer] root 42 [kvm-irqfd-clean] root 65 [kswapd0] root 66 [fsnotify_mark] root 67 [ecryptfs-kthrea] root 86 [cmdq_auto_relea] root 87 [cmdq_task] root 88 [irq/239-hdmi hp] root 89 [irq/25-mt6397-p] root 90 [spi32766] root 96 [irq/14-chromeos] root 102 [kpsmoused] root 123 [vpu_wdt] root 124 [mtk-vcodec-enc] root 125 [irq/102-ekth350] root 127 [irq/131-ekth300] root 128 [cros_usb_pd_log] root 130 [dm_bufio_cache] root 131 [irq/15-11240000] root 133 [mmcqd/0] root 134 [mmcqd/0boot0] root 135 [mmcqd/0boot1] root 136 [mmcqd/0rpmb] root 137 [system] root 138 [carveout] root 139 [chunk] root 140 [binder] root 141 [irq/17-rt5645] root 142 [ipv6_addrconf] root 155 [hwrng] root 156 [pvr_timer] root 157 [pvr_defer_free] root 158 [pvr_device_wdg] root 159 [pvr_cacheop] root 160 [deferwq] root 161 [irq/50-gpio-dis] root 162 [mtk-vcodec-dec] root 163 [mtk-mdp] root 164 [mdp_wdt_wq] root 165 [irq/249-mtk-svs] root 166 [pvr_fence_sync_] root 171 [kdmflush] root 172 [bioset] root 173 [kverityd] root 174 [bioset] root 175 [kworker/2:1H] root 176 [ext4-rsv-conver] root 177 [kworker/3:1H] root 182 [kworker/0:1H] root 183 [kworker/1:1H] root 207 udevd --daemon root 218 [jbd2/mmcblk0p1-] root 219 [ext4-rsv-conver] root 221 [jbd2/mmcblk0p8-] root 222 [ext4-rsv-conver] root 334 frecon --daemon --clear 0xfffefefe --frame- root 339 [loop0] root 341 [kdmflush] root 349 [bioset] root 350 [kcryptd_io] root 351 [kcryptd] root 352 [bioset] root 356 [jbd2/dm-1-8] root 357 [ext4-rsv-conver] root 360 [pvr_workqueue] root 361 [pvr_workqueue] root 362 [pvr_workqueue] root 365 [frecon] <defunct> root 370 /sbin/agetty - 9600 xterm root 374 /sbin/agetty - 9600 xterm root 379 /sbin/agetty - 9600 xterm 603 489 /usr/bin/arc_camera_service root 517 [loop1] 202 523 /usr/lib/systemd/systemd-journald root 544 [loop2] root 547 [loop3] 201 580 dbus-daemon --system --fork 202 629 /usr/sbin/rsyslogd -n -f /etc/rsyslog.chrom 219 737 /usr/sbin/wpa_supplicant -u -s -O/run/wpa_s root 886 [irq/282-cros-ec] 228 1235 /usr/bin/powerd --log_dir=/var/log/power_ma 229 1291 /usr/sbin/daisydog root 1298 session_manager root 1342 /sbin/debugd soyeomul 1346 /opt/google/chrome/chrome --ppapi-flash-pat 207 1354 tcsd 223 1363 chapsd --auto_load_system_token root 1447 cryptohomed --noclose --direncryption root 1492 /usr/bin/shill --log-level=0 --log-scopes= root 1494 [metrics_client] <defunct> 202 1495 /usr/bin/logger --priority daemon err --tag soyeomul 1502 /opt/google/chrome/chrome --type=zygote --e root 1503 [cfg80211] soyeomul 1532 /opt/google/chrome/nacl_helper_bootstrap /o soyeomul 1535 /opt/google/chrome/nacl_helper_nonsfi soyeomul 1538 /opt/google/chrome/chrome --type=zygote --e soyeomul 1557 /opt/google/chrome/chrome --type=gpu-proces soyeomul 1562 /opt/google/chrome/chrome --type=utility -- soyeomul 1609 /opt/google/chrome/chrome --type=broker root 1743 /bin/sh /usr/bin/periodic_scheduler 3600 14 root 1745 /bin/sh /usr/bin/periodic_scheduler 86400 6 root 1786 /bin/sh /usr/bin/periodic_scheduler 86400 6 root 1810 minijail0 -u cras -g cras -G -n --uts -v -l 226 1816 /usr/sbin/mtpd -minloglevel=1 238 1823 avahi-daemon: running [31d2b8c39b0dfde4288a 241 1825 /usr/sbin/ModemManager --log-level=INFO 230 1831 /usr/bin/permission_broker 213 1861 /usr/bin/cros-disks --foreground --log_leve 284 1875 /usr/bin/arc-networkd 232 1876 /sbin/minijail0 -n -S /usr/share/policy/con root 1889 upstart-socket-bridge --daemon 232 1901 /usr/sbin/conntrackd root 1904 /usr/bin/arc-networkd --ip_helper_fd=5 600 1912 /usr/bin/cras --dsp_config=/etc/cras/HANA/d 238 1915 avahi-daemon: chroot helper root 1976 [MWIFIEX_WORK_QU] root 1977 [MWIFIEX_RX_WORK] root 1978 [ksdioirqd/mmc2] root 1979 update_engine root 1996 [btmrvl_main_ser] root 1997 [hci0] root 1998 [hci0] root 2142 /bin/sh /usr/bin/periodic_scheduler 3600 60 root 2255 /bin/sh /usr/bin/periodic_scheduler 21600 3 root 2270 minijail0 -u bluetooth -g bluetooth -G -i - root 2274 /sbin/minijail0 -T static --profile=minimal root 2283 timberslide --device_log=/sys/kernel/debug/ root 2284 minijail0 -u bluetooth -g bluetooth -G -i - root 2287 minijail0 -i -p -v -r --uts -l --profile mi root 2313 /sbin/minijail0 -u bluetooth -g bluetooth - 218 2328 /usr/libexec/bluetooth/bluetoothd --nodetac 234 2334 /usr/bin/tlsdated -- /usr/bin/tlsdate -v -C root 2349 /usr/bin/anomaly_collector root 2362 [krfcommd] root 2377 /usr/bin/tlsdated -- /usr/bin/tlsdate -v -C 218 2642 /usr/bin/btdispatch --vmodule= 218 2643 /usr/bin/newblued --vmodule= root 2735 metrics_daemon root 2738 minijail0 --profile minimalistic-mountns -b root 2744 /usr/bin/memd soyeomul 2834 /opt/google/chrome/chrome --type=renderer - 249 3166 /opt/google/easy_unlock/easy_unlock 304 3349 /opt/google/drive-file-stream/drivefs -o rw soyeomul 3376 /opt/google/chrome/chrome --type=ppapi-brok soyeomul 3518 /opt/google/chrome/chrome --type=renderer - soyeomul 3531 /bin/bash /usr/bin/crosh soyeomul 3680 /bin/bash /usr/bin/crosh soyeomul 3681 /bin/bash -l root 4009 [kauditd] soyeomul 4958 /opt/google/chrome/chrome --type=renderer - soyeomul 6664 /opt/google/chrome/chrome --type=renderer - soyeomul 6676 /opt/google/chrome/nacl_helper_bootstrap /o root 13255 [kworker/2:1] root 13847 [kworker/0:1] root 14054 [kworker/u9:0] root 14099 [kworker/3:1] root 14183 [kworker/1:2] root 16897 [kworker/u8:13] root 16898 [kworker/u8:14] 224 17706 /sbin/dhcpcd -B -q -4 -R -P mlan0=wifi_any_ root 18194 sudo LD_LIBRARY_PATH=/usr/local/lib startgn root 18199 sh -e /usr/local/bin/enter-chroot -t gnome message+ 18469 dbus-daemon --system --fork root 18475 /lib/systemd/systemd-logind root 18499 su -s /bin/sh -c export SHELL='/bin/bash';' soyeomul 18506 /usr/bin/xinit /usr/local/bin/croutonxinitr soyeomul 18515 /usr/lib/xorg/Xorg -nolisten tcp -logfile / soyeomul 18606 /bin/sh -e /usr/local/bin/croutonxinitrc-wr soyeomul 18615 /bin/sh -e /usr/local/bin/croutonpowerd --d soyeomul 18616 /bin/sh -e /usr/local/bin/croutontriggerd soyeomul 18628 /bin/sh -e /usr/local/bin/croutontriggerd soyeomul 18630 /bin/sh -e /usr/local/bin/croutontriggerd soyeomul 18631 mawk -W Interactive function output(s) { pr soyeomul 18634 hexdump -e 4/4 "%u " " " 2/2 "%u " " " 1/4 soyeomul 18635 hexdump -e 4/4 "%u " " " 2/2 "%u " " " 1/4 soyeomul 18636 hexdump -e 4/4 "%u " " " 2/2 "%u " " " 1/4 soyeomul 18637 hexdump -e 4/4 "%u " " " 2/2 "%u " " " 1/4 soyeomul 18638 hexdump -e 4/4 "%u " " " 2/2 "%u " " " 1/4 soyeomul 18639 hexdump -e 4/4 "%u " " " 2/2 "%u " " " 1/4 soyeomul 18640 hexdump -e 4/4 "%u " " " 2/2 "%u " " " 1/4 soyeomul 18647 xbindkeys -fg /etc/crouton/xbindkeysrc.scm soyeomul 18654 /usr/lib/gnome-session/gnome-session-binary soyeomul 18671 dbus-launch --autolaunch d54670e0e82f464cbc soyeomul 18672 /usr/bin/dbus-daemon --syslog-only --fork - soyeomul 18708 /usr/bin/dbus-launch --exit-with-session -- soyeomul 18709 /usr/bin/dbus-daemon --syslog --fork --prin soyeomul 18718 /usr/bin/ssh-agent /usr/bin/im-launch /usr/ soyeomul 18727 /usr/bin/nabi soyeomul 18730 /usr/lib/at-spi2-core/at-spi-bus-launcher soyeomul 18735 /usr/bin/dbus-daemon --config-file=/usr/sha soyeomul 18739 /usr/lib/at-spi2-core/at-spi2-registryd --u soyeomul 18781 /usr/bin/gnome-screensaver --no-daemon soyeomul 18786 /usr/lib/gvfs/gvfsd soyeomul 18791 /usr/lib/gvfs/gvfsd-fuse /home/soyeomul/.gv soyeomul 18805 /usr/bin/gnome-keyring-daemon --start --com soyeomul 18820 /usr/bin/gnome-shell root 18827 /usr/lib/upower/upowerd soyeomul 18855 /usr/bin/pulseaudio --start --log-target=sy soyeomul 18872 ibus-daemon --xim --panel disable soyeomul 18876 /usr/lib/ibus/ibus-dconf soyeomul 18878 /usr/lib/ibus/ibus-x11 --kill-daemon soyeomul 18880 /usr/lib/ibus/ibus-portal soyeomul 18892 /usr/lib/gnome-shell/gnome-shell-calendar-s soyeomul 18897 /usr/lib/evolution/evolution-source-registr soyeomul 18905 /usr/lib/gnome-online-accounts/goa-daemon soyeomul 18915 /usr/lib/gnome-online-accounts/goa-identity root 18920 /usr/lib/accountsservice/accounts-daemon root 18925 /usr/lib/policykit-1/polkitd --no-debug geoclue 18930 /usr/lib/geoclue-2.0/geoclue -t 5 root 18935 /sbin/wpa_supplicant -u -s -O /run/wpa_supp root 18937 /usr/lib/aarch64-linux-gnu/boltd root 18941 /usr/sbin/ModemManager soyeomul 18948 /usr/lib/dconf/dconf-service soyeomul 18954 /usr/lib/gvfs/gvfs-udisks2-volume-monitor root 18958 /usr/lib/udisks2/udisksd soyeomul 18982 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor soyeomul 18987 /usr/lib/gvfs/gvfs-goa-volume-monitor soyeomul 18993 /usr/lib/gvfs/gvfs-mtp-volume-monitor soyeomul 18998 /usr/lib/gvfs/gvfs-afc-volume-monitor root 19004 /usr/lib/packagekit/packagekitd soyeomul 19008 /usr/lib/gnome-settings-daemon/gsd-power soyeomul 19009 /usr/lib/gnome-settings-daemon/gsd-print-no soyeomul 19013 /usr/lib/gnome-settings-daemon/gsd-rfkill soyeomul 19015 /usr/lib/gnome-settings-daemon/gsd-screensa soyeomul 19021 /usr/lib/gnome-settings-daemon/gsd-sharing soyeomul 19025 /usr/lib/gnome-settings-daemon/gsd-smartcar soyeomul 19031 /usr/lib/gnome-settings-daemon/gsd-xsetting soyeomul 19036 /usr/lib/gnome-settings-daemon/gsd-sound soyeomul 19037 /usr/lib/gnome-settings-daemon/gsd-wacom soyeomul 19048 /usr/lib/gnome-settings-daemon/gsd-a11y-set soyeomul 19049 /usr/lib/gnome-settings-daemon/gsd-clipboar soyeomul 19053 /usr/lib/gnome-settings-daemon/gsd-color soyeomul 19054 /usr/lib/gnome-settings-daemon/gsd-datetime soyeomul 19057 /usr/lib/gnome-settings-daemon/gsd-housekee soyeomul 19058 /usr/lib/gnome-settings-daemon/gsd-keyboard soyeomul 19063 /usr/lib/gnome-settings-daemon/gsd-media-ke soyeomul 19064 /usr/lib/gnome-settings-daemon/gsd-mouse soyeomul 19074 /usr/lib/gnome-settings-daemon/gsd-printer colord 19109 /usr/lib/colord/colord soyeomul 19136 /usr/lib/gnome-disk-utility/gsd-disk-utilit soyeomul 19172 /usr/lib/evolution/evolution-calendar-facto root 19176 /usr/sbin/cron soyeomul 19191 /usr/lib/evolution/evolution-calendar-facto soyeomul 19205 /usr/lib/evolution/evolution-addressbook-fa soyeomul 19214 /usr/lib/evolution/evolution-addressbook-fa soyeomul 19227 /usr/lib/ibus/ibus-engine-simple soyeomul 19257 /usr/bin/ssh-agent -D -a /home/soyeomul/.ca soyeomul 19261 ssh -f soyeomul@gcp -L 2000:localhost:25 -N soyeomul 19303 /usr/lib/firefox/firefox soyeomul 19378 /usr/lib/firefox/firefox -contentproc -chil soyeomul 19415 /usr/lib/firefox/firefox -contentproc -chil soyeomul 19493 /usr/lib/firefox/firefox -contentproc -chil soyeomul 19569 /opt/google/chrome/chrome --type=renderer - soyeomul 19701 /usr/bin/gnome-software --gapplication-serv soyeomul 19703 update-notifier root 19739 /usr/lib/fwupd/fwupd soyeomul 19970 /usr/lib/deja-dup/deja-dup-monitor soyeomul 20116 emacs26 soyeomul 20312 /usr/lib/firefox/firefox -contentproc -chil root 20364 [kworker/u9:2] soyeomul 20769 /usr/lib/firefox/firefox -contentproc -chil root 20928 [kworker/u8:0] soyeomul 21236 /usr/lib/gnome-terminal/gnome-terminal-serv soyeomul 21242 bash root 21904 [kworker/3:0] root 22122 [kworker/1:0] root 23295 [kworker/u8:1] root 23308 [kworker/u9:3] root 23312 [kworker/2:2] root 24012 [kworker/0:2] root 24210 /usr/bin/coreutils --coreutils-prog-shebang root 24317 [kworker/u9:1] root 24359 /usr/bin/coreutils --coreutils-prog-shebang root 24363 /usr/bin/coreutils --coreutils-prog-shebang root 24367 /usr/bin/coreutils --coreutils-prog-shebang root 24371 /usr/bin/coreutils --coreutils-prog-shebang root 24735 [kworker/0:0] soyeomul 24834 sleep 15 soyeomul 24844 sleep 15 soyeomul 24845 python3 ./4.py soyeomul 24848 /bin/sh -c ps -ef > /tmp/ps.txt soyeomul 24849 ps -ef (bionic)soyeomul@localhost:~/test$
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
답변 먹튀 하셨네요. https://kldp.org
답변 먹튀 하셨네요. https://kldp.org/node/161562
죄송합니다. 제가 실수했습니다.
포럼은 삭제가 안되는 줄 모르고 글을 남겼는데, 해결을 해서 제 딴에는 글을 지워놓으면 댓글을 안달아 주실줄 알았습니다. 친절하게 답변해주셨네요.. 너무너무 감사합니다. 앞으로 이런 실수 없도록 주의하겠습니다. 감사합니다.
질문자께서 원하는바를 정확히 모르겠지만, 일단
질문자께서 원하는바를 정확히 모르겠지만, 일단 추측으로 코드를 작성해봤습니다.
--
^고맙습니다 감사합니다_^))//
이렇게 짤 수도 있지요
간결한 코드 stdout 기억할께요 감사합니다^^^
간결한 코드 stdout 기억할께요
감사합니다^^^
Traceback (most recent call
파이썬 3.6.7 환경에서 위와 같은 에러가 나서..
"text=True" 를 "universal_newlines=True" 으로 코드 수정해서 실행시키니 성공했습니다.
기록을 위하야 댓글 남깁니다.
--
^고맙습니다 감사합니다_^))//
Quote:Changed in version 3.7:
https://docs.python.org/3/library/subprocess.html
정확한 정보 주셔서 감사드립니다.
정확한 정보 주셔서 감사드립니다.
우분투에서 3.7 파이썬 설치후에 코드도 좀 보완해서 테스트해봤습니다.
세부적인 곳을 긁어주셔서 정말 감사드립니다^^^
--
^고맙습니다 감사합니다_^))//
파이썬 판번호 식별에 sys.hexversion 적용해봤습니다~
참고문헌: https://docs.python.org/3/library/sys.html#sys.hexversion
정보 공유차원에서 댓글로 남깁니다. 코드 실험결과는 아래서 확인할 수 있어요~
https://gitlab.com/soyeomul/test/raw/2dbfddd688c5b41b8f01ca3db769e0add68d66e9/333.py
꾸벅,,,
추가...
CMD 열이 사실 대게 긴줄도 있습니다.
CMD 열이 사실 대게 긴줄도 있습니다.
그래서 코드를 좀 더 보완했씁니다.
--
^고맙습니다 감사합니다_^))//
댓글 달기