{"id":58201,"date":"2023-01-30T03:01:55","date_gmt":"2023-01-29T17:01:55","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/ITblog\/?p=58201"},"modified":"2023-01-29T19:19:27","modified_gmt":"2023-01-29T09:19:27","slug":"linux-chaining-commands-on-command-line-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/linux-chaining-commands-on-command-line-primer-tutorial\/","title":{"rendered":"Linux Chaining Commands on Command Line Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Linux\/chaining_ksh_commands_interactively_vs_crontab.jpg\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Linux Chaining Commands on Command Line Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/\/Linux\/chaining_ksh_commands_interactively_vs_crontab.jpg\" title=\"Linux Chaining Commands on Command Line Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Linux Chaining Commands on Command Line Primer Tutorial<\/p><\/div>\n<p>With the RJM Programming domain we are regularly dealing with a Linux (CentOS) web server operating system and its associated command line we access via ssh command (usually from our macOS Terminal application command) &#8230;<\/p>\n<p><code><br \/>\nssh -p 22 [username]@[RJM Programming domain IP address]<br \/>\n<\/code><\/p>\n<p>In that Linux world, we like to think about &#8220;Interactive&#8221; usages (usually one offs) and &#8220;Scheduled&#8221; usages (usually via <a target=_blank title='crontab information from computerhope ... thanks' href='http:\/\/www.computerhope.com\/jargon\/c\/cron.htm'>crontab<\/a> (and quite often in combination with <a target=_blank title='Linux or unix curl information from computerhope' href='http:\/\/www.computerhope.com\/unix\/curl.htm'>curl<\/a>)) usually using commands and\/or Korn Shell scripting.<\/p>\n<p>There are occasions when we find an issue with the &#8220;Scheduled&#8221; side of operations, or the cards it was dealt (ie. human error writing the Blog Posting content), and to circumvent the waiting of a day to rerun the &#8220;Scheduled&#8221; work, we &#8230;<\/p>\n<ol>\n<li>fix the human error(s) writing the Blog Posting content<\/li>\n<li>we run an &#8220;Interactive&#8221; version of relevant &#8220;Scheduled&#8221; commands to set things right<\/li>\n<\/ol>\n<p>With Linux and <a target=_blank title='Korn Shell' href='https:\/\/en.wikipedia.org\/wiki\/KornShell'>Korn shell<\/a> it is very useful to know that the semicolon ( ie. ; ) delimiter can chain commands together, and even better than the type ahead buffering of VAX\/VMS days, we can see it all assembled before our eyes ahead of committing to &#8220;letting it fly&#8221;, so to speak.  At the command line prompt we first type &#8230;<\/p>\n<ul>\n<li><code>crontab -l<\/code><\/li>\n<li>highlight (with mouse down) first command of use in Terminal application, right click, Copy<\/li>\n<li>use Terminal application&#8217;s Edit -&gt; Paste to slot into the command line<\/li>\n<li>at command line type <i> ; <\/i><\/li>\n<li>repeat three steps above for rest of relevant commands in order<\/li>\n<li>if you are happy to leave all this running and logout at the end, type in <i> exit<\/i><\/li>\n<li>hit Return key to start off running these commands<\/li>\n<\/ul>\n<p>The <i> exit<\/i> idea is not as radical as you might think, especially because the Terminal application rerunning the same ssh command will remember this whole chained together arrangement, on logging in, via the up arrow way you can look through the history of command line commands when working with Linux (or macOS, for that matter).<\/p>\n<p>Of course, if stuff ups occur regularly <strike><a target=_blank title='?' href='https:\/\/www.google.com\/search?q=take+a+bex+youtube&#038;rlz=1C5CHFA_enAU973AU973&#038;oq=take+a+bex+youtube&#038;aqs=chrome..69i57j33i160l2.4760j0j7&#038;sourceid=chrome&#038;ie=UTF-8#fpstate=ive&#038;vld=cid:33b4c90a,vid:q0rsiC-C8hs'>take a Bex<\/a><\/strike> you can write this chain of commands into a Korn Shell script file with a first record of <i>#!\/bin\/ksh<\/i> (perhaps in this scenario, not needing the <i> exit<\/i>) (you could call <i>myKornShell.ksh<\/i> for example) and make executable via permission arrangement like (at its loosest being) <i>chmod 777 myKornShell.ksh<\/i> where all you need to do to perform the equivalent would be to go, at the similar command line environment &#8230;<\/p>\n<p><code><br \/>\n.\/myKornShell.ksh<br \/>\n<\/code><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d58201' onclick='var dv=document.getElementById(\"d58201\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"https:\/\/www.rjmprogramming.com.au\/ITblog\/tag\/command-line\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d58201' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>With the RJM Programming domain we are regularly dealing with a Linux (CentOS) web server operating system and its associated command line we access via ssh command (usually from our macOS Terminal application command) &#8230; ssh -p 22 [username]@[RJM Programming &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/linux-chaining-commands-on-command-line-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,29,37],"tags":[53,168,195,4230,4231,233,234,4229,265,274,284,2147,3884,566,617,4227,677,707,2178,885,907,2738,4228,1105,1190,1252,4232,2542,1386,1411],"class_list":["post-58201","post","type-post","status-publish","format-standard","hentry","category-elearning","category-operating-system","category-tutorials","tag-access","tag-buffer","tag-centos","tag-chain","tag-chaining","tag-command","tag-command-line","tag-commands","tag-copy","tag-crontab","tag-curl","tag-delimiter","tag-exit","tag-history","tag-interactive","tag-korn","tag-korn-shell","tag-linux","tag-macos","tag-operating-system-2","tag-paste","tag-procedure","tag-scheduled","tag-script","tag-ssh","tag-terminal","tag-type-ahead","tag-type-ahead-buffer","tag-vms","tag-web-server"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/58201"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=58201"}],"version-history":[{"count":6,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/58201\/revisions"}],"predecessor-version":[{"id":58207,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/58201\/revisions\/58207"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=58201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=58201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=58201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}