diff --git a/index-lab.adoc b/index-lab.adoc index 04f7249..a51242b 100644 --- a/index-lab.adoc +++ b/index-lab.adoc @@ -71,7 +71,7 @@ TIP: Absolute basics === http://docs.swarmlab.io/SwarmLab-HowTos/labs/ls/array-1_ls.adoc.html[Bash - Associative array examples^] -=== http://docs.swarmlab.io/SwarmLab-HowTos/labs/ls/heredocs_ls.adoc.html[Bash - variable indirect expansion^] +=== http://docs.swarmlab.io/SwarmLab-HowTos/labs/ls/heredocs_ls.adoc.html[Bash - Heredocs, Positional Parameters^] :hardbreaks: diff --git a/index-lab.adoc.html b/index-lab.adoc.html index 5a2018a..384a93a 100644 --- a/index-lab.adoc.html +++ b/index-lab.adoc.html @@ -465,7 +465,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
  • 2.2. The proc filesystem
  • 2.3. VIM - A simple workflow example with the vim editor
  • 2.4. Bash - Associative array examples
  • -
  • 2.5. Bash - variable indirect expansion
  • +
  • 2.5. Bash - Heredocs, Positional Parameters
  • 3. Internet of things (IoT) @@ -587,7 +587,7 @@ Absolute basics
    -

    2.5. Bash - variable indirect expansion

    +

    2.5. Bash - Heredocs, Positional Parameters



    @@ -921,7 +921,7 @@ This tutorial demonstrates some common nmap port scanning scena

    diff --git a/index-lab.adoc.pdf b/index-lab.adoc.pdf index 36804ef..37057d0 100644 --- a/index-lab.adoc.pdf +++ b/index-lab.adoc.pdf @@ -6,8 +6,8 @@ /Keywords (iot, swarm, Linux, OS, Sec) /Creator (Asciidoctor PDF 1.5.0.beta.5, based on Prawn 2.2.2) /Producer (Apostolos rootApostolos@swarmlab.io) -/ModDate (D:20201130224240+00'00') -/CreationDate (D:20201130224745+00'00') +/ModDate (D:20201130230542+00'00') +/CreationDate (D:20201130230828+00'00') >> endobj 2 0 obj @@ -50,7 +50,7 @@ endobj >> endobj 6 0 obj -<< /Length 23842 +<< /Length 23843 >> stream q @@ -656,7 +656,7 @@ ET BT 79.9485 533.216 Td /F3.0 10.5 Tf -<42617368202d207661726961626c6520696e64697265637420657870616e73696f6e> Tj +[<42617368202d2048657265646f63732c20506f736974696f6e616c20506172> 20.0195 <616d6574657273>] TJ ET 0.0 0.0 0.0 SCN @@ -665,9 +665,9 @@ ET 0.6627 0.6627 0.6627 SCN BT -251.8876 533.216 Td +278.6101 533.216 Td /F3.0 10.5 Tf -<2e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e20> Tj +<2e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e202e20> Tj ET 0.0 0.0 0.0 SCN @@ -2063,7 +2063,7 @@ endobj >> endobj 33 0 obj -<< /Length 6535 +<< /Length 6556 >> stream q @@ -2086,7 +2086,7 @@ ET BT 83.574 786.666 Td /F1.0 18 Tf -<42617368202d207661726961626c6520696e64697265637420657870616e73696f6e> Tj +[<42617368202d2048657265646f63732c20506f736974696f6e616c20506172> 20.0195 <616d6574657273>] TJ ET 0.0 0.0 0.0 SCN @@ -2573,7 +2573,7 @@ endobj /URI (http://docs.swarmlab.io/SwarmLab-HowTos/labs/ls/heredocs_ls.adoc.html) >> /Subtype /Link -/Rect [83.574 781.41 394.938 805.89] +/Rect [83.574 781.41 439.3436 805.89] /Type /Annot >> endobj @@ -3479,7 +3479,7 @@ endobj endobj 59 0 obj << /Limits [(__anchor-top) (_internet_of_things_iot)] -/Names [(__anchor-top) 9 0 R (_an_introduction_to_linux) 24 0 R (_bash_associative_array_examples) 31 0 R (_bash_variable_indirect_expansion) 35 0 R (_create_a_mote_with_raspberry_piarduino) 44 0 R (_create_swarmlab_cluster) 52 0 R (_frequently_asked_questions) 74 0 R (_get_swarmlab_io_certificates) 19 0 R (_how_do_i_ask_a_good_question) 76 0 R (_install_docker) 16 0 R (_install_dual) 21 0 R (_internet_of_things_iot) 37 0 R] +/Names [(__anchor-top) 9 0 R (_an_introduction_to_linux) 24 0 R (_bash_associative_array_examples) 31 0 R (_bash_heredocs_positional_parameters) 35 0 R (_create_a_mote_with_raspberry_piarduino) 44 0 R (_create_swarmlab_cluster) 52 0 R (_frequently_asked_questions) 74 0 R (_get_swarmlab_io_certificates) 19 0 R (_how_do_i_ask_a_good_question) 76 0 R (_install_docker) 16 0 R (_install_dual) 21 0 R (_internet_of_things_iot) 37 0 R] >> endobj 60 0 obj @@ -5583,7 +5583,7 @@ endobj endobj 114 0 obj << /Border [0 0 0] -/Dest (_bash_variable_indirect_expansion) +/Dest (_bash_heredocs_positional_parameters) /Subtype /Link /Rect [60.24 530.15 79.9485 544.43] /Type /Annot @@ -5596,21 +5596,21 @@ endobj /URI (http://docs.swarmlab.io/SwarmLab-HowTos/labs/ls/heredocs_ls.adoc.html) >> /Subtype /Link -/Rect [79.9485 530.15 250.7625 544.43] +/Rect [79.9485 530.15 274.6708 544.43] /Type /Annot >> endobj 116 0 obj << /Border [0 0 0] -/Dest (_bash_variable_indirect_expansion) +/Dest (_bash_heredocs_positional_parameters) /Subtype /Link -/Rect [79.9485 530.15 250.7625 544.43] +/Rect [79.9485 530.15 274.6708 544.43] /Type /Annot >> endobj 117 0 obj << /Border [0 0 0] -/Dest (_bash_variable_indirect_expansion) +/Dest (_bash_heredocs_positional_parameters) /Subtype /Link /Rect [541.1705 530.15 547.04 544.43] /Type /Annot @@ -6207,7 +6207,7 @@ endobj >> endobj 186 0 obj -<< /Title +<< /Title /Parent 181 0 R /Count 0 /Prev 185 0 R @@ -6842,238 +6842,238 @@ xref 0000000633 00000 n 0000000684 00000 n 0000000956 00000 n -0000024851 00000 n -0000025932 00000 n -0000026104 00000 n -0000026146 00000 n -0000026195 00000 n -0000026239 00000 n -0000026407 00000 n -0000031450 00000 n -0000031871 00000 n -0000031915 00000 n -0000031959 00000 n -0000032178 00000 n -0000032361 00000 n -0000032405 00000 n -0000032681 00000 n -0000032725 00000 n -0000032947 00000 n -0000032991 00000 n -0000033035 00000 n -0000033242 00000 n -0000033286 00000 n -0000033491 00000 n -0000033534 00000 n -0000033736 00000 n -0000033938 00000 n -0000033982 00000 n -0000034193 00000 n -0000040781 00000 n -0000041195 00000 n -0000041239 00000 n -0000041450 00000 n -0000041494 00000 n -0000041538 00000 n -0000041747 00000 n -0000041791 00000 n -0000042001 00000 n -0000042229 00000 n -0000042462 00000 n -0000042506 00000 n -0000042724 00000 n -0000042768 00000 n -0000042979 00000 n -0000043023 00000 n -0000054267 00000 n -0000054673 00000 n -0000054848 00000 n -0000054892 00000 n -0000055097 00000 n -0000055141 00000 n -0000055355 00000 n -0000055399 00000 n -0000055612 00000 n -0000055656 00000 n -0000056158 00000 n -0000056758 00000 n -0000056971 00000 n -0000069505 00000 n -0000069898 00000 n -0000069942 00000 n -0000070169 00000 n -0000070213 00000 n -0000070427 00000 n -0000070471 00000 n -0000070685 00000 n -0000070729 00000 n -0000070942 00000 n -0000081792 00000 n -0000082191 00000 n -0000082235 00000 n -0000082441 00000 n -0000082485 00000 n -0000082666 00000 n -0000082841 00000 n -0000083007 00000 n -0000083169 00000 n -0000083342 00000 n -0000083500 00000 n -0000083659 00000 n -0000083785 00000 n -0000084005 00000 n -0000084134 00000 n -0000084262 00000 n -0000084402 00000 n -0000084680 00000 n -0000084823 00000 n -0000084965 00000 n -0000085089 00000 n -0000085313 00000 n -0000085439 00000 n -0000085565 00000 n -0000085682 00000 n -0000085801 00000 n -0000085937 00000 n -0000086145 00000 n -0000086284 00000 n -0000086423 00000 n -0000086555 00000 n -0000086764 00000 n -0000086899 00000 n -0000087033 00000 n -0000087195 00000 n -0000087400 00000 n -0000087564 00000 n -0000087728 00000 n -0000087872 00000 n -0000088085 00000 n -0000088232 00000 n -0000088378 00000 n -0000088523 00000 n -0000088737 00000 n -0000088885 00000 n -0000089032 00000 n -0000089166 00000 n -0000089303 00000 n -0000089425 00000 n -0000089637 00000 n -0000089761 00000 n -0000089885 00000 n -0000090022 00000 n -0000090161 00000 n -0000090312 00000 n -0000090532 00000 n -0000090685 00000 n -0000090838 00000 n -0000090966 00000 n -0000091179 00000 n -0000091309 00000 n -0000091439 00000 n -0000091560 00000 n -0000091683 00000 n -0000091819 00000 n -0000092026 00000 n -0000092165 00000 n -0000092303 00000 n -0000092443 00000 n -0000092659 00000 n -0000092801 00000 n -0000092943 00000 n -0000093072 00000 n -0000093289 00000 n -0000093421 00000 n -0000093552 00000 n -0000093679 00000 n -0000093896 00000 n -0000094026 00000 n -0000094155 00000 n -0000094299 00000 n -0000094528 00000 n -0000094675 00000 n -0000094821 00000 n -0000094982 00000 n -0000095199 00000 n -0000095363 00000 n -0000095526 00000 n -0000095666 00000 n -0000095882 00000 n -0000096024 00000 n -0000096166 00000 n -0000096292 00000 n -0000096509 00000 n -0000096638 00000 n -0000096766 00000 n -0000096904 00000 n -0000097111 00000 n -0000097252 00000 n -0000097393 00000 n -0000097535 00000 n -0000097678 00000 n -0000097756 00000 n -0000097949 00000 n -0000098152 00000 n -0000098497 00000 n -0000098712 00000 n -0000098948 00000 n -0000099126 00000 n -0000099311 00000 n -0000099537 00000 n -0000099757 00000 n -0000100104 00000 n -0000100380 00000 n -0000100646 00000 n -0000100907 00000 n -0000101073 00000 n -0000101313 00000 n -0000101613 00000 n -0000101807 00000 n -0000102004 00000 n -0000102226 00000 n -0000102478 00000 n -0000102686 00000 n -0000102915 00000 n -0000103163 00000 n -0000103511 00000 n -0000103771 00000 n -0000103953 00000 n -0000104193 00000 n -0000104431 00000 n -0000104552 00000 n -0000104823 00000 n -0000105094 00000 n -0000115111 00000 n -0000115332 00000 n -0000116695 00000 n -0000117610 00000 n -0000127911 00000 n -0000128127 00000 n -0000129490 00000 n -0000130406 00000 n -0000131505 00000 n -0000131731 00000 n -0000132032 00000 n -0000133170 00000 n -0000140376 00000 n -0000140602 00000 n -0000141965 00000 n -0000142881 00000 n -0000143894 00000 n -0000144118 00000 n -0000144421 00000 n -0000145560 00000 n -0000149031 00000 n -0000149246 00000 n -0000150609 00000 n -0000151524 00000 n -0000156955 00000 n -0000157176 00000 n -0000157537 00000 n +0000024852 00000 n +0000025933 00000 n +0000026105 00000 n +0000026147 00000 n +0000026196 00000 n +0000026240 00000 n +0000026408 00000 n +0000031451 00000 n +0000031872 00000 n +0000031916 00000 n +0000031960 00000 n +0000032179 00000 n +0000032362 00000 n +0000032406 00000 n +0000032682 00000 n +0000032726 00000 n +0000032948 00000 n +0000032992 00000 n +0000033036 00000 n +0000033243 00000 n +0000033287 00000 n +0000033492 00000 n +0000033535 00000 n +0000033737 00000 n +0000033939 00000 n +0000033983 00000 n +0000034194 00000 n +0000040803 00000 n +0000041217 00000 n +0000041261 00000 n +0000041473 00000 n +0000041517 00000 n +0000041561 00000 n +0000041770 00000 n +0000041814 00000 n +0000042024 00000 n +0000042252 00000 n +0000042485 00000 n +0000042529 00000 n +0000042747 00000 n +0000042791 00000 n +0000043002 00000 n +0000043046 00000 n +0000054290 00000 n +0000054696 00000 n +0000054871 00000 n +0000054915 00000 n +0000055120 00000 n +0000055164 00000 n +0000055378 00000 n +0000055422 00000 n +0000055635 00000 n +0000055679 00000 n +0000056184 00000 n +0000056784 00000 n +0000056997 00000 n +0000069531 00000 n +0000069924 00000 n +0000069968 00000 n +0000070195 00000 n +0000070239 00000 n +0000070453 00000 n +0000070497 00000 n +0000070711 00000 n +0000070755 00000 n +0000070968 00000 n +0000081818 00000 n +0000082217 00000 n +0000082261 00000 n +0000082467 00000 n +0000082511 00000 n +0000082692 00000 n +0000082867 00000 n +0000083033 00000 n +0000083195 00000 n +0000083368 00000 n +0000083526 00000 n +0000083685 00000 n +0000083811 00000 n +0000084031 00000 n +0000084160 00000 n +0000084288 00000 n +0000084428 00000 n +0000084706 00000 n +0000084849 00000 n +0000084991 00000 n +0000085115 00000 n +0000085339 00000 n +0000085465 00000 n +0000085591 00000 n +0000085708 00000 n +0000085827 00000 n +0000085963 00000 n +0000086171 00000 n +0000086310 00000 n +0000086449 00000 n +0000086581 00000 n +0000086790 00000 n +0000086925 00000 n +0000087059 00000 n +0000087221 00000 n +0000087426 00000 n +0000087590 00000 n +0000087754 00000 n +0000087898 00000 n +0000088111 00000 n +0000088258 00000 n +0000088404 00000 n +0000088552 00000 n +0000088766 00000 n +0000088917 00000 n +0000089067 00000 n +0000089201 00000 n +0000089338 00000 n +0000089460 00000 n +0000089672 00000 n +0000089796 00000 n +0000089920 00000 n +0000090057 00000 n +0000090196 00000 n +0000090347 00000 n +0000090567 00000 n +0000090720 00000 n +0000090873 00000 n +0000091001 00000 n +0000091214 00000 n +0000091344 00000 n +0000091474 00000 n +0000091595 00000 n +0000091718 00000 n +0000091854 00000 n +0000092061 00000 n +0000092200 00000 n +0000092338 00000 n +0000092478 00000 n +0000092694 00000 n +0000092836 00000 n +0000092978 00000 n +0000093107 00000 n +0000093324 00000 n +0000093456 00000 n +0000093587 00000 n +0000093714 00000 n +0000093931 00000 n +0000094061 00000 n +0000094190 00000 n +0000094334 00000 n +0000094563 00000 n +0000094710 00000 n +0000094856 00000 n +0000095017 00000 n +0000095234 00000 n +0000095398 00000 n +0000095561 00000 n +0000095701 00000 n +0000095917 00000 n +0000096059 00000 n +0000096201 00000 n +0000096327 00000 n +0000096544 00000 n +0000096673 00000 n +0000096801 00000 n +0000096939 00000 n +0000097146 00000 n +0000097287 00000 n +0000097428 00000 n +0000097570 00000 n +0000097713 00000 n +0000097791 00000 n +0000097984 00000 n +0000098187 00000 n +0000098532 00000 n +0000098747 00000 n +0000098983 00000 n +0000099161 00000 n +0000099346 00000 n +0000099572 00000 n +0000099792 00000 n +0000100139 00000 n +0000100415 00000 n +0000100697 00000 n +0000100958 00000 n +0000101124 00000 n +0000101364 00000 n +0000101664 00000 n +0000101858 00000 n +0000102055 00000 n +0000102277 00000 n +0000102529 00000 n +0000102737 00000 n +0000102966 00000 n +0000103214 00000 n +0000103562 00000 n +0000103822 00000 n +0000104004 00000 n +0000104244 00000 n +0000104482 00000 n +0000104603 00000 n +0000104874 00000 n +0000105145 00000 n +0000115162 00000 n +0000115383 00000 n +0000116746 00000 n +0000117661 00000 n +0000127962 00000 n +0000128178 00000 n +0000129541 00000 n +0000130457 00000 n +0000131556 00000 n +0000131782 00000 n +0000132083 00000 n +0000133221 00000 n +0000140427 00000 n +0000140653 00000 n +0000142016 00000 n +0000142932 00000 n +0000143945 00000 n +0000144169 00000 n +0000144472 00000 n +0000145611 00000 n +0000149082 00000 n +0000149297 00000 n +0000150660 00000 n +0000151575 00000 n +0000157006 00000 n +0000157227 00000 n +0000157588 00000 n trailer << /Size 234 /Root 2 0 R /Info 1 0 R >> startxref -158452 +158503 %%EOF diff --git a/labs/ls/heredocs_ls.adoc b/labs/ls/heredocs_ls.adoc index a55bac1..39aac42 100644 --- a/labs/ls/heredocs_ls.adoc +++ b/labs/ls/heredocs_ls.adoc @@ -25,7 +25,6 @@ Assuming you're already logged in == heredoc - === Exercise [source,bash] @@ -64,9 +63,25 @@ done echo "" echo "" + +cat << FOE > testfile.sh + +declare -A array=( + [1,0]="first name" + [1,1]="second name" + [2,0]="third name" + [3,0]="foo bar" + [test 1]="test bar" + ) +EOF +) + ---- + + + === expansion [source,bash] @@ -76,3 +91,70 @@ win="real_fc" # $win is "real_fc" echo "${!win}" # we print the variable linked by $win's content ---- +== Bash Positional Parameters + +- vim testvar.sh +- cut-paste +- chmod +x ./testvar.sh +- ./testvar.sh a1 a2 a3 a4 a5 a6 a7 a8 a9 10 11 12 13 + + +[source,bash] +---- + +echo $# +echo $@ +echo $? + + +cat <<'EOF' +$# = number of arguments. +$@ = what parameters were passed. +$* = what parameters were passed. +$? = was last command successful. Answer is 0 which means 'yes' +EOF + + + +cat << FOE > testfile.sh +#!/bin/bash +RUSER=$1 +ID=$2 +SERVICE=$3 +SERVICE_STACK=$4 +VNCport=$5 +RREPLICAS=$6 +RREGION=$7 +TTYport=$8 +PASSWORDrw=$9 +PASSWORDview=${10} +GIT_TUTOR=${11} +REBOOT=${12} +USERscope=${13} +FOE +chmod +x ./testfile.sh + +#./testfile.sh +# +cat << 'FOE' > testfile1.sh +#!/bin/bash +RUSER=$1 +ID=$2 +SERVICE=$3 +SERVICE_STACK=$4 +VNCport=$5 +RREPLICAS=$6 +RREGION=$7 +TTYport=$8 +PASSWORDrw=$9 +PASSWORDview=${10} +GIT_TUTOR=${11} +REBOOT=${12} +USERscope=${13} +FOE +chmod +x ./testfile1.sh + +---- + +== extras +