
The following line items explain the script entries above:
#Search all files for text using ssh free#
Free course: Deploying containerized applications. A practical introduction to container terminology. The following is the script I use to test the servers: 1 #!/bin/bashĦ echo "ServerName,IP,PING,DNS,SSH" > "$output_file"Ĩ tail -n +2 "$input_file" | while IFS=, read -r host ip _Ģ2 if nc -z -w3 "$ip" 22 > /dev/null thenĢ8 echo "Host = $host IP = $ip" PING_STATUS = $ping_status DNS_STATUS = $dns_status SSH_STATUS = $ssh_statusĢ9 echo "$host,$ip,$ping_status,$dns_status,$ssh_status" > $output_file (Converting the spreadsheet to/from CSV was done manually and will not be covered in this article.) The script Different scenarios might require that you store the information to a file for reasons such as clarity, troubleshooting, auditing, or being able to analyze the information's structure and other types of content that are there. In other cases, you don't need to have the file physically written because you're only interested in the result (and the data structure is really simple). So, when should you use one method or the other? Well, in some cases, the text file already exists, like the /etc/hosts file, for instance. In many cases, you do have a text file, but in others, you simply use the output of some previous command as if it were a text file. Note: Writing to stdout and reading from stdin using pipes is like using a virtual text file. I cover examples of both cases in this article.
In certain situations, you can use text files as an output to be shared with regular users as well. Text files are also simple and convenient data sources for a sysadmin's typical operations. This allows an administrator with the right permissions to examine the files and make changes if required. Something that I like in Linux (and in Unix-like systems in general) is that configurations and properties are contained in text files.