You use the chexec command to indicate that a (shell script) file can be executed.
CIT 38100: CHAP 06 PRACTICE QUIZ.1.A high-level language is a computer language that uses English-likeexpressions.a.Trueb.False Show 2.Shell scripts run less quickly than compiled programs. Get answer to your question and much more 3.Shell scripts can automatically access variables created and assigned on thecommand line. Get answer to your question and much more 4.You can use the chexec command to indicate that a shell script file can beexecuted. Get answer to your question and much more 5.You should omit spaces when you assign a variable without using single ordouble quotation marks around its value.a.Trueb.False 6.A ____ is a name consisting of letters, numbers, or characters and is used toreference the contents of a variable. Some of the tools I’ve tried over time: func, clusterIT , pssh , java ssh, paramiko , Fabric. Most of them are python based, and as my daily programming language is becoming ruby, I started looking at the ways on how to integrate using shell scripts in Ruby. This article will list the things I’ve learned during this journey. If you would ask a modern sysadmin, he would tell you that I should start writing recipes using puppet or chef. These tools server their purpose really well, but sometimes you want to script something without installing all the daemon stuff. Executing local commandsI learned that Ruby has 6 ways to execute shell commands using various options (Exec, System, Backticks, IO#popen, Open3#popen3, Open4#popen4). The Open4#open4 is the most comprehensive as it allows to check the exit code, wait for the command to finish. While researching I found other useful libraries for doing local stuff:
Executing remote commandsFor automating SSH stuff in Ruby, the defacto standard is the Net::SSH, Net::SFTP , Net::SCP library http://net-ssh.rubyforge.org/ used in various ruby deploy tools. While this will suit most of your commands I found it missing the following features:
Other Ruby tools I’ve found :
It took me some time to find out how to get the exit code of a remote command using Net-SSH. The blogpost Non Ruby Tools that look interesting:
Synchronize directories (Rsync)To transfer and synchronize large directories , I normally use rsync over ssh instead of scp or sftp. The following links describe efforts to get the rsync command ported to ruby.
Testing ScriptsInspired by the post How to run and test shell scripts from Ruby, I understood when executing a command (local or remote), you always need to check the exit code to see if it executed ok. Rolling my own approachAs much as I like these tools, they are often a ruby implementation of command line command. The result is that they often provide less features as their commandline equivalent. Also by abstracting the commands, a sysadmin used to executing commands by shell, looses touch with the original commands execute on the machines.
The difference in approach is that underhood, I still use the full commands , so that when running the script, I can log the actual commands and see that what’s happening. This kind of log will make much more sense to a sysadmin and can easily generate an installation manual for a machine. The resulting code might look like this: |