IBM Developer is your one-stop location for getting hands-on training and learning in-demand skills on relevant technologies such as generative AI, data science, AI, and open source.
æ¡ä»¶1. /bin/shã®å®ä½ãbashã®ãã£ã¹ããªãã¥ã¼ã·ã§ã³ RHEL CentOS Scientific Linux Fedora Amazon Linux openSUSE Arch Linux (èªãè¨å®ããå ´å: Debian, Ubuntu) æ¡ä»¶2. åä½ç°å¢ CGI (ã¬ã³ã¿ã«ãµã¼ãã§ãããã¡ãªCGIã¢ã¼ãã®PHPçãå«ã) Passenger(Ruby) æ¡ä»¶3. ããã°ã©ã å 容 Passengerã¯å ¨æ»äº¡ *1 systemã `command`ã '| /usr/lib/sendmail' ãªã©ã§å¤é¨ã³ãã³ãå®è¡ *2 PHPã®mailãmb_send_mailããã®ä»ãã¬ã¼ã ã¯ã¼ã¯çãä»ããã¡ã¼ã«éä¿¡ *3 以ä¸ã¯æ¡ä»¶1ãä¸è¦ æ示çã«bashãå¼ã¶ å é 㧠#!/bin/bash ã #!/usr/bin/env bash ãã¦ããããã°ã©ã ãå®è¡ (rbenv
ããã§ã¯Bashã®èå¼±æ§ ShellShockã®å½±é¿ãåã¶ã±ã¼ã¹ã¨ãã¦æ å ±ãåºã¦ãããã®ãã¾ã¨ãã¾ããè¨è¼æ å ±ã¯piyokangoãè¦ã¤ããæ å ±ãã¾ã¨ãã¦ããã ãã§ãããå½è©²èå¼±æ§ã«ããå½±é¿ãåã¶ã±ã¼ã¹ããã¹ã¦ç¶²ç¾ ãã¦ããããã§ã¯ããã¾ããã®ã§ã注æãã ããã é¢é£æ å ± bashã®èå¼±æ§(CVE-2014-6271) #ShellShock ã®é¢é£ãªã³ã¯ãã¾ã¨ãã¦ã¿ã å½±é¿ãåã¶ã±ã¼ã¹ã®åææ¡ä»¶ 対象ã®ã·ã¹ãã ã§Bashã®èå¼±æ§(CVE-2014-6271ãCVE-2014-7169)ãä¿®æ£ããã¦ããªã æ»ææ¹æ³ æ¹æ³ å ·ä½ä¾ æ¡ä»¶ è½åç ExploitãHTTPãªã¯ã¨ã¹ããã¡ã¼ã«çã使ã£ã¦éãä»ãã (åè)BASHã®èå¼±æ§ã§CGIã¹ã¯ãªããã«ã¢ã¬ããã¦ã¿ã¾ãã æ»æè ã対象ã¸ç´æ¥æ¥ç¶å¯è½ ååç Exploitãä»è¾¼ãã ç½ ãã¼ã¸ãè¨ç½®ãæ»æ対象ã«è¸ã¾ãã (åè)ãã¡ã¤ã¢ã¦ã©ã¼ã«å ã®
bashã«èå¼±æ§ã確èªãããã¨ãã¦é¨ãã«ãªã£ã¦ãã¾ããããã§ã¯CVE-2014-6271ã«é¢ããæ å ±ãã¾ã¨ãã¾ãã #è¨è¼å 容ã«ã¤ãã¦ã誤ã£ã¦ããã追è¨ããæ¹ãããçæ å ±ããããã¾ããã@piyokangoã¾ã§ãé£çµ¡ãé¡ããã¾ãã èå¼±æ§æ å ± èå¼±æ§ã®æ称 ShellShock Bashbug CVEçªå· Bashå¨ãã§çºè¡ããã¦ããCVEã¯6ã¤ããã®å 詳細ãä¸æãªã®ã2ã¤ã(CVE-2014-6277,CVE-2014-6278) CVE çºè¦è æ³å®è å¨ ç¹è¨ CVE-2014-6271 Stephane Chazelasæ° ä»»æã®ã³ã¼ãå®è¡ ShellShockã®çºç«¯ã¨ãªã£ããã°ã CVE-2014-7169 Tavis Ormandyæ° ä»»æã®ã³ã¼ãå®è¡ CVE-2014-6271ä¿®æ£æ¼ãã«ããèå¼±æ§ CVE-2014-7186 Redhat DoS ã¡ã¢ãªç ´å£(Out-of-Bo
ç°å¢å¤æ°ã«ä»è¾¼ã¾ããã³ã¼ããå®è¡ãã¦ãã¾ãBASHã®èå¼±æ§ã CGIã¹ã¯ãªããã«å½±é¿ãä¸ããã試ãã¦ã¿ããçµæã¯æ²æ¨ãªæãã« Tweet 2014å¹´9æ25æ¥ å¶ç°å¤§è²´ ãã®è¨äºã¯2014å¹´ã®ãã®ã§ã æãã Bash specially-crafted environment variables code injection attack ãªããã®ã§é¨ãã«ãªã£ã¦ããã®ã§ããã£ããæå ã® Apacheã§è©¦ãã¦ã¿ã¾ããã /hoge.cgiã¨ããURIã§å®è¡ãããããã«ãä¸è¡ã®ã¡ãã»ã¼ã¸ãåºåããã ãã® CGIã¹ã¯ãªãããè¨ç½®ãã¾ãããã£ããããªãã®å ¥åãã¯ã©ã¤ã¢ã³ãå´ããåãä»ãã¦ããªãããå±éºã®ããããããªãè¦ãã¾ãã #!/bin/sh echo "Content-type: text/plain" echo echo "Hi! I'm an ordinary CGI script w
Read one line from the standard input, (or from a file) and assign the word(s) to variable name(s). Syntax read [-ers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-r] [-s] [-t timeout] [-u fd] [name...] Key -a aname The words are assigned to sequential indices of the array variable aname, starting at 0. aname is unset before any new values are assigned. Other name argument
æååã®ä¸ã«ã¯ç©ºç½æåãç¡ãã¨ããã¨ãbashã®çµã¿è¾¼ã¿æ©è½ã ãã§åºæ¥ã¾ãã #!/bin/bash A=123456789abc1defg0123456789 B=/$A/ âå é ãæ«å°¾ã«ç¹å®æåãå«ã¾ãã¦ããå ´åã®èæ ® IFS=1 âããã«ç¹å®æå(ä¸æåã«éã) set -- $B echo $(($#-1)) 空ç½ãè¨å·ãå«ã¾ãã¦ããå ´åã§ãbashãç¡ãå ´å #!/bin/sh A=123456789abc1defg0123456789 LENA=`expr length "$A"` B=`echo "$A" | sed s/1//g` âåé¤ããã¨çããªã LENB=`expr length "$B"` echo `expr $LENA - $LENB` ãã£ã¡ã®æ¹ããããããããã
å¤æ°ã®å¤ããã«ããªã©ã®æ¡ä»¶ã«ãããä»£å ¥ããå¤ã表示ããå 容ãå¤ãããã¨ãã§ããã ${var:-word} varã«å¤ãå ¥ã£ã¦ããªããªãwordãå¤ã¨ãã¦è¿ã ${var:=word} varã«å¤ãå ¥ã£ã¦ããªããªãwordãä»£å ¥ãã ${var:?word} varã«å¤ãå ¥ã£ã¦ããªããªãwordåºåãã ${var:+word} varã«å¤ãå ¥ã£ã¦ãããwordãå¤ã¨ãã¦è¿ã :ã¯çç¥å¯è½ã§çç¥ããå ´åãå¤æ°ã®å¤ãæªè¨å®ããã«ãä»£å ¥ããã¦ããå ´åã«ãã«æåã å ¥ã£ã¦ããå¤æ°ã¨ãã¦æ±ããæªå®ç¾©ã®å¤æ°ã®å ´åã¯å¤ãå ¥ã£ã¦ããªãå¤æ°ã¨ãã¦æ±ãã $ var1=abc $ echo ${var1:-xyz} #å¤ãå ¥ã£ã¦ããã°ãã®ã¾ã¾è¡¨ç¤º abc $ var1= $ echo ${var1:-xyz} #å¤ãå ¥ã£ã¦ããªããã°-以éã表示 xyz $ echo $var1 #å¤ã¯å ¥ã£ã¦ããªãã¾ã¾ $
cronããç«ã¡ä¸ããããbashã¯ãã¡ãã¨.bash_profileããã¡ãèªã¿è¾¼ãã§ãã 以ä¸ãã®è§£èª¬ $ cat .bash_profile A=xxx $ crontab -l * * * * * bash --login -c 'echo `date` "->" $A >> /tmp/a.txt' $ tail -f /tmp/a.txt 2008å¹´ 1æ 30æ¥ æ°´ææ¥ 16:14:01 JST -> xxx 2008å¹´ 1æ 30æ¥ æ°´ææ¥ 16:15:01 JST -> xxx 2008å¹´ 1æ 30æ¥ æ°´ææ¥ 16:16:01 JST -> xxx 2008å¹´ 1æ 30æ¥ æ°´ææ¥ 16:17:01 JST -> xxx
ã¦ã¼ã¶ã¼å®ç¾©å¤æ°ã®ä½¿ãæ¹ å¤æ°ã¯ãã·ã§ã«ã®ä¸çãã¨ãã«è±èªã®ããã¥ã¡ã³ãã§ã¯ããã©ã¡ã¼ã¿ãã¨å¼ã°ãã¦ãã¾ãããæ¥æ¬èªã§ãã©ã¡ã¼ã¿ã¨ããã¨ã©ããéãæå³ã«ã¨ãããã¡ãªã®ã§ãããã§ã¯ãå¤æ°ãã¨å¼ãã¨ã«ãããã¨æãã¾ããã§ã¯ã·ã§ã«ã¹ã¯ãªããã«ããããå¤æ°ãã®åæ±ã¨ç¹å¾´ã«ã¤ãã¦è¦ã¦ãããã¨ã«ãã¾ãããã ã·ã§ã«ãã·ã§ã«ã¹ã¯ãªããã§å¤æ°ãå®ç¾©ããå ´åã¯ã ã®ããã«è¨è¿°ãã¾ããã¨ãã«åãã£ã¦å¤æ°ã宣è¨ãããããå¿ è¦ã¯ããã¾ããï¼å®£è¨ãããã¨ãã§ãã¾ããï¼ãâ=âã®ä¸¡å´ã«ã¹ãã¼ã¹ããããããã¦ã¯ããã¾ãããCè¨èªãªã©ã®å¤æ°ä»£å ¥ãªã©ã®éã«ã¹ãã¼ã¹ããããçã®ããæ¹ã¯æ°ãã¤ãã¦ãã ããã æ ¼ç´ãããå¤ãåç §ããå ´åã¯ãå¤æ°ã®å é ã«â$âãã¤ãã¾ãããããã«echoã使ã£ã¦æ¨æºåºåã«å¤æ°ã表示ãã¦ã¿ã¾ãã
Many people hack together shell scripts quickly to do simple tasks, but these soon take on a life of their own. Unfortunately shell scripts are full of subtle effects which result in scripts failing in unusual ways. Itâs possible to write scripts which minimise these problems. In this article, I explain several techniques for writing robust bash scripts. How often have you written a script that br
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}