I-Shell, i-Bash kunye ne-Scripts: Konke malunga ne-Shell Scripting.

Kweli thuba litsha (Ungeniso # 8) malunga "Funda Iskripthi SikaShell" Siza kugxila ngakumbi kwithiyori kunokuziqhelanisa. Oko kukuthi, asizukufaka okanye sifunde ikhowudi okanye sifakele isoftware ethile (iphakheji), kodwa siya kuphengulula ukuba yintoni umhlaba Ukushicilela kweShell Ukuthetha ngokufanelekileyo, ngeempendulo zemibuzo emincinci kodwa ethe ngqo, eboniswe ngezantsi, ukucacisa ukuza kuthi ga ngoku okuninzi okufundisiweyo, okungabhekisi ngqo kwikhowudi yangaphakathi ecwangcisiweyo:

Ukushicilela kweShellYintoni uShell kwiNkqubo yokuSebenza ye-GNU / Linux?

I-Shell ethi ngesiSpanish ithetha i-CONCHA (iqokobhe, ikhava, ukhuseleko). Ukusetyenziswa kweli gama kwiNkqubo yokuSebenza kubhekisa kutoliko lomyalelo weNkqubo yokuSebenza. Ngokubanzi, luphawu olusebenzayo lombhalo, olubonakaliswe ngohlobo lweTheminali (ikhonsoli) kwaye isetyenziselwa indawo ezintathu zomsebenzi obalulekileyo:

1- Lawula i-OS,
2. -Sebenzisa usetyenziso kwaye unxibelelane nabo, kwaye
3.- khonza njengendawo esisiseko yenkqubo.

Zininzi SO, GNU / Linux zisalawulwa ngokukuko ngokuhlela iifayile zoqwalaselo, ngeTheminali. Njengomgaqo ngokubanzi, ezi zisendleleni eya kuyo: «/ njl., kunye nakwizikhombisi ezithile zesicelo ngasinye. Umzekelo, inkqubo Lilo (emele iLinux Loader) iqulunqwe ngokuhlela ifayile yokubhaliweyo ebizwe njenge "/Etc/lilo/lilo.conf". Kwimeko yeenkqubo (izicelo), ezi ziqalisiwe (zenziwe / zenziwe zasebenza) ngokubhala igama lezizakusebenza, ukuba lifunyenwe kwindlela (indlela emiselweyo) yazo zonke izinto ezenziwayo, njengoko iqhele ukwenzeka "/ Usr / umgqomo" , okanye ngokuchwetheza igama lezinto eziza kuqala ezandulelwa ngu: ./, ukusuka kulawulo apho zibekwe khona.

Konke oku kuyaziwa nakowuphi na umsebenzisi weShell. Nangona kunjalo, amandla ayo njengendawo yenkqubo ayaziwa kakuhle kwaye ayanconywa. Izikripthi (iinkqubo) ezenziwe kwiShell azidingi kuqulunqwa. UShell ubatolikela ngomgca ngomgca. Ke ngoko, ezi ziyaziwa okanye zibizwa ngokuba ziiShells Scripts, kwaye zinokwahluka ukusuka kwimiyalelo elula ukuya kuthotho oluntsonkothileyo lwemiyalelo yokuqalisa i-OS ngokwayo. une syntax ecocekileyo (ebonakalayo) (yokwakha, uku-odola), ebenza indawo elungileyo yokuqalisa kwihlabathi lenkqubo.

Yintoni iShell Scripting?

Yindlela (ubuchule / ubuchule) bokuyila nokwenza iSkripthi (ifayile ye-automation file) usebenzisa iShell (ngokukhethekileyo) yeNkqubo yokuSebenza, okanye isiHlomelo seTeksti (iGrafiki okanye iTheminali). Olu luhlobo lolwimi lwenkqubo olutolikwa ngokubanzi. Oko kukuthi, ngelixa uninzi lweenkqubo zihlanganisiwe (zifakwe kwikhowudi), kuba ziguqulwe ngokusisigxina zangumgaqo othile (okhethekileyo) ngaphambi kokuba zenziwe (inkqubo yokuhlanganisa), iskripthi esineqokobhe lihlala likwimo yoqobo (ikhowudi yemvelaphi yayo) kwaye Ukutolikwa komyalelo ngomyalelo ngalo lonke ixesha zisenziwa. Nangona kunokwenzeka ukuba iincwadi zeempendulo zinokudityaniswa ngokunjalo, nangona ingaqhelekanga.

Zithini iimpawu zeenkqubo ezisekwe kwinkqubo engaphantsi kweShell Scripting?

Kulula ukubhala (inkqubo), kodwa ngeendleko eziphezulu zokuqhubekeka xa besenziwa.

Basebenzisa iitoliki endaweni yeekhomputha ukuqhuba

Banobudlelwane bonxibelelwano kunye nezinto ezibhalwe ngezinye iilwimi zenkqubo.

4.- Iifayile eziqulathiweyo zigcinwa njengombhalo ocacileyo.

5.- Uyilo lokugqibela (ikhowudi) ihlala incinci kunaleyo inokulingana ngolwimi oluhlanganisiweyo.

Zeziphi ezona ntlobo zaziwayo zeelwimi phantsi kweShell Scripting?

Umsebenzi wolwimi kunye nolawulo lweqokobhe:

cmd.exe (Windows NT, Windows CE, OS / 2),
b) COMMAND.COM (DOS, Windows 9x),
c), i-bash, i-AppleScript, sh, kunye
d) IJScript ngeWindows script,
e) VBScript ngeWindows script Host,
f) I-REXX, phakathi kwezinye ezininzi.

2.- Isikripthi se-GUI (iiLwimi zeMacros):

a) IHotkey ezenzekelayo,
b) Ukuzenzekelayo,
c) Lindela,
d) Isixhobo esizisebenzelayo, phakathi kwabanye.

Ulwimi olubhaliweyo lwezicelo ezithile:

a) Isenzo sokubhaliweyo kwiFlash,
b) IMATLABI,
c) Iskripthi se-MIRC,
d) I-QuakeC, phakathi kwezinye.

Iprogram yeWebhu (yamaphepha anamandla):

a) Kwicala leseva:

-I-PHP,
-ASP (Amaphepha eSeva eSebenzayo),
Amaphepha eJavaServer,
-ColdFusion,
- IPTSCRAE,
-Lasso,
Iskripthi se-MIVA,
- SMX,
-XSLT, phakathi kwabanye.

b) Kwicala lomxhasi:

-IJavaScript,
-IJScript,
-VBScript,
-Tcl, phakathi kwabanye.

Iilwimi ezi-5 zokulungisa iilwimi:

-WKK,
-U-Perl,
- unxaniwe,
- XSLT,
-Bash, phakathi kwabanye.

Iinjongo ezi-6 zokutshintsha kweelwimi:

- APL,
-Boo,
-Dylan,
-Ferite,
-Imivuzo,
-O,
-Lisp,
-Lua,
- IIMPENDU (M),
- INTSHA,
-Nuva,
-U-Perl,
-I-PHP,
- iPython,
-Ruby,
Inkqubo
- Ukuthetha kancinci,
- iSuperCard,
-Tcl,
-Uhlaziyo, phakathi kwabanye.

Yintoni iBash kwi-GNU / Linux?

Yinkqubo yekhompyuter umsebenzi wayo kukutolika iiodolo. Isekwe kwi Iqokobhe le Unix kwaye iyaxhasa POSIX. Yayibhalelwe iprojekthi ye-GNU kwaye iqokobhe elisisiseko kuninzi losasazo lweLinux.

Yintoni iSkripthi seShell kwiGNU / Linux?

Imibhalo yeShell ziluncedo kakhulu. Ngumbono olungileyo ukubhala ezo mfuno sinazo emva koko sihlele izikripthi ezisenzela lo msebenzi. Okwangoku, lixesha lokuba uzibuze ukuba yintoni kanye kanye le iscript. Yifayile yokubhaliweyo, equlathe uthotho lwemiyalelo yegobolondo, leyo inkqubo iyenza ngocwangco, ukusuka phezulu kuye ezantsi. Ukuzihlela, kufuneka umhleli wombhalo kuphela, onje ngeEmacs, Vi, Nano, phakathi kwezinto ezininzi ezikhoyo. Zigcinwa ngolwandiso ".sh" (okanye ngaphandle kwayo, kwezinye iimeko) kwaye ziqhutywa kwiShell zisebenzisa i-command: sh script name.sh. Izikripthi ziziphatha ngendlela efanayo nemiyalelo yeqokobhe.

Indlela yokufundisa endiyisebenzisayo "Funda Iskripthi SikaShell" Iyasebenza kwaye ithe ngqo, Oko kukuthi, ukuvavanya iSkripthi esisebenza ngokupheleleyo, ukubola, ukufunda isigwebo ngesivakalisi, umgca ngomgca, ukuyalela ngomyalelo, okwahlukileyo ngokuguquguqukayo, de uqonde ukuba into nganye isebenza njani ngokwahlukeneyo kwaye isebenza njani kwikhowudi ngokubanzi. Luhlobo Ukubuyela umva kweNjineli okanye kwiNkqubo yeSoftware. Konke oku ukulungiselela ulwazi, kulungiswe (kulungiselelwe) kwaye kwabelwane ngalo, ukulungiselela isibonelelo esihlangeneyo kunye nolawulo olungcono kunye nokwenza ngcono iiNkqubo zokuSebenza zasimahla.

Ibaleka kwaye isebenza njani kwi-GNU / Linux Shell?

Isinyathelo sokuqala ekusebenzeni neShell kukuqhuba igobolondo. Into ebonakala ngathi kukukholelwa kubuvuvu inesizathu sayo. Kokunye kusasazo lomsebenzisi olujolise kakhulu kwi-GNU / Linux, iqokobhe lifihlekile. Ngokwesiqhelo, ibizwa ngokuba yiKonsole, iTheminali, iTheminali X, okanye into efanayo. Olunye ukhetho kukusebenzisa ikhonsoli ebonakalayo. Sebenzisa: Ctrl + Alt + f1, okanye f2, okanye f3 ukuya f7 okanye f8, kuxhomekeke kunikezelo lweGNU / Linux olisebenzisayo. Elona Shell lisetyenzisiweyo kwi-GNU / Linux yiBhash, nangona zikhona ezinye, ezinje nge-ksh okanye i-C Shell. Kwimeko yam, ikakhulu kupapasho lwam ndisebenzisa iBash Shell.

Unikwe iSkripthi esenziwe kwiBhash Shell ebizwa hello_world.sh oku kulandelayo kunokuchazwa:

Okuqukethwe:

#! / bin / ibash
echo molo umhlaba

Yoyisakala:

Umgca wokuqala weskripthi
#! / bin / ibash

Ibonisa inkqubo ekufuneka iskripthi isebenze kuyo. Ukuba le nkqubo ayifumaneki, kuya kubakho impazamo.

Umgca wesibini weskripthi
echo molo umhlaba

Yenza umyalelo we-echo kunye neengxoxo zeHlabathi zeHlabathi, ezibangela ukuba ziboniswe kwisikrini.

Ukubulawa: Singaqhuba iskripthi ngeendlela ezimbini

Ukucela itoliki ukuba iqhube iskripthi:
# bash hello_world.sh

Inokuqhutywa njenge:
# sh hello_world.sh

Kodwa ekubeni i-Shell yakho echanekileyo ingafunwanga, inokusebenza isiqingatha. Ngokufanelekileyo, uShell ubongozwe kumgca wokuqala yeyona isetyenzisiweyo ukuyiphumeza.

Ungaqhuba iskripthi ngokuthe ngqo ngolu hlobo lulandelayo:
# ./hello_world.sh

Qaphela: ./ ibonisa ukubaleka kulawulo lwangoku.

Into eseleyo ekusafuneka ihlalutywe yikhowudi oyifaka kuyo. Ndiyathemba ukuba uhlala uthanda (ezinye ngaphezulu kwezinye, ngokweemfuno zokufunda kunye nolwazi) olu luhlu Ukushicilela kweShell.

Zininzi amakhonkco amahle kwesi sihloko kwiwebhu, kodwa ndikushiyela esi sikhokelo sincinci silapha apha UkusukaLinux.net Kwaye le enye Isikhokelo sangaphandle.

Kude kube yinto elandelayo!


Umxholo wenqaku uyabambelela kwimigaqo yethu imigaqo yokuziphatha yokuhlela. Ukuxela impazamo cofa apha.

Izimvo ezi-13, shiya ezakho

Shiya uluvo lwakho

Idilesi yakho ye email aziyi kupapashwa. ezidingekayo ziphawulwe *

*

*

  1. Uxanduva lwedatha: UMiguel Ángel Gatón
  2. Injongo yedatha: Ulawulo lwe-SPAM, ulawulo lwezimvo.
  3. Umthetho: Imvume yakho
  4. Unxibelelwano lwedatha: Idatha ayizukuhanjiswa kubantu besithathu ngaphandle koxanduva lomthetho.
  5. Ukugcinwa kweenkcukacha
  6. Amalungelo: Ngalo naliphi na ixesha unganciphisa, uphinde uphinde ucime ulwazi lwakho.

  1.   d4ny sitsho

    Lilo .. Linux Loader .. ezinye ulwazi oluhle kakhulu .. enkosi .. salu2 d4ny.-

  2.   Ing. UJoseph Albert sitsho

    Ndibulisa kubo bonke abo balandela ikhosi ekwi-Intanethi ye "Funda iShell Scripting" kungekudala siza kuqhubeka nezinye iincwadi ezisisiseko ukuze siqhubeke nokwabelana ngolwazi kwaye siqhubeke nokuncokola nalo sonke.

    Ndiyathemba ukuba uza kuhlala ubukele kuba kungekudala ndiza kuqala ngeekhowudi ezihambele phambili kodwa zivezwe ngendlela eqondakalayo ngokubonakalayo ngaphandle kokuntsonkotha kwayo.

    Khumbula ukuba ngeShell Scripting unokwenza izinto ezininzi ezintsonkothileyo ezinqamlezayo (iiDistros ezahlukeneyo) usebenzisa iifayile ezincinci kakhulu. Ndizokushiya le screencast incinci yento endizokufundisa yona kungekudala, kwabo baqhubeka nokubukela ikhosi, kwaye nge-50Kb kuphela ithembisa okuninzi! Kwaye sisiqingatha kuphela sento enokwenziwa ngeShell Scripting.

    I-LPI-SB8 yoVavanyo lweScreenCast (I-LINUX POST INSTALL-ISIKRIPTHI BICENTENARIO 8.0.0)
    (lpi_sb8_adaptation-audiovisual_2016.sh / 43Kb)

    Jonga iScreencast: https://www.youtube.com/watch?v=cWpVQcbgCyY

    1.    UAlberto Cardona sitsho

      Molo, igalelo lakho liyamangalisa, enkosi kakhulu !!
      Ndinamathandabuzo amancinci, ngaba ndingayicwangcisa i-compiler kunye ne-bash?
      Okanye ubuncinci bokuhlalutya ubhalo?
      unawo amandla?

  3.   Ing. UJoseph Albert sitsho

    Imibuliso kubo bonke abo balandela ikhosi ekwi-Intanethi ye "Funda iShell Scripting" kungekudala sizakuqhubeka nezinye iincwadi ezisisiseko ukuze siqhubeke nokwabelana ngolwazi kwaye siqhubeke nokuncokola nalo sonke. Ndiyathemba ukuba uza kuhlala ubukele kuba kungekudala ndiza kuqala ngeekhowudi ezihambele phambili kodwa zivezwe ngendlela eqondakalayo ngokubonakalayo ngaphandle kokuntsokotha kwayo.

    Khumbula ukuba ngeShell Scripting unokwenza izinto ezininzi ezintsonkothileyo ezinqamlezayo (iiDistros ezahlukeneyo) usebenzisa iifayile ezincinci kakhulu. Ndizokushiya le screencast incinci yento endizokufundisa yona kungekudala, kwabo baqhubeka nokubukela ikhosi, kwaye nge-50Kb kuphela ithembisa okuninzi! Kwaye sisiqingatha kuphela sento enokwenziwa ngeShell Scripting.

    I-LPI-SB8 yoVavanyo lweScreenCast (I-LINUX POST INSTALL-ISIKRIPTHI BICENTENARIO 8.0.0)
    (lpi_sb8_adaptation-audiovisual_2016.sh / 43Kb)

    Jonga iScreencast: https://www.youtube.com/watch?v=cWpVQcbgCyY

  4.   Alberto sitsho

    Molo Jose,
    Kuqala ndiyabulela ngokwabelana ngolwazi lwakho. Amanqaku akho anomdla kakhulu.

    Izinto ezimbini, ndicinga ukuba kubaluleke kakhulu ukusebenzisa iikowuti eziphindwe kabini "Molo weHlabathi" kunye nokufumana imveliso ecocekileyo yeskripthi sethu ngokuphuma 0

  5.   Ing. UJoseph Albert sitsho

    Enkosi ngegalelo lakho, kwiskripthi esilandelayo uza kubona ukusebenzisa ukuphuma 0, ikhefu, kunye nabanye!

  6.   Ngaba Willarmand sitsho

    Ukubulisa
    Inomdla kakhulu, uyenza ibonakale ilula; Ngoku, ndiye ndafumanisa ukuba andinakho ukwenza inkqubo kwi-Linux nge-cron okanye nge-shutdown / suspend / hibernate, kunye nesiqalo esizenzekelayo sokuqalisa sisebenzisa i-rtc wake command, andazi ukuba iscript esine lo myalelo singanceda, okanye inokulandela ikron kunye t ngaphandle kokwenza nantoni na, okanye ayinakwenziwa, okanye yenziwa ngenye indlela, okanye ndinomdla omkhulu, kodwa kwiWindows kulula ukuyenza. Ndifuna ukuya kwiLinux, kodwa kubalulekile kum ukucwangcisa ukuvala / ukunqumamisa / ukubamba i-hibernate kwaye iPC iqale ngokwayo. Imibuliso.

  7.   Ing. UJoseph Albert sitsho
  8.   Ngaba Willarmand sitsho

    Enkosi, ndiza kuzifunda kakuhle, into eza kundinceda. Imibuliso.

  9.   UEduardo Cuomo sitsho

    Ngexesha elithile elidlulileyo ndiqalise iprojekthi, endikholelwa ukuba yenye yohlobo lwayo. Ngumzekelo wokuqala wesakhelo seBhash. Ifuna iBash kuphela kwinkqubo.
    Ukuba omnye umntu unomdla, bayamenywa ukuba bazame kwaye basebenzisane!

    https://github.com/reduardo7/bashx

    Nibuliso!

    1.    icikilishe sitsho

      Eduardo othandekayo, ndicinga ukuba yiprojekthi entle, mhlawumbi ungabelana ngayo noluntu lonke lwe-desdelinux, khumbula ukuba ungapapasha inqaku malunga neprojekthi yakho kwiwebhusayithi yethu, ukuba awazi ukuba ungayenza njani, ndincoma ukuba ufunde https://blog.desdelinux.net/guia-redactores-editores/ ziphi ezona ndlela zilungileyo zokwenza amanqaku kwi-desdelinux kunye nenkqubo yokwenza. Ngokunokwenzeka eluntwini kulungile ukuba uqale wazi malunga nezibonelelo zeprojekthi yakho kwaye okwesibini ufunde ukwenza olu hlobo lwento. Siyakumema kwaye simema abanye ukuba babhengeze iiprojekthi zabo nathi kunye noluntu ngokubanzi olusingqongileyo.

  10.   UMiguel Urosa Ruiz sitsho

    Molweni ngemini elungileyo.
    Ndimtsha kwihlabathi lolawulo lomatshini weLinux, kwaye bendifuna ukwazi ukuba ucebisa ntoni ngayo: ksh, bash, perl, php, python….
    Ndiyabonga kakhulu kunye nokubulisa.
    UMiguel.