Skip to content
Advertisement

Tag: bash

Shell script for remote SSH

I’m new to shell scripts, and I have centos running. I want to write a shell script that ssh a remote machine and execute a bunch of commands. The problem I’m facing is how to provide the username, the password, the remote machine address, and the private access key to a command that shall connect the remote machine. I’ve Google’d

Run scripts remotely via SSH

I need to collect user information from 100 remote servers. We have public/private key infrastructure for authentication, and I have configured ssh-agent command to forward key, meaning i can login on any server without password prompt (auto login). Now I want to run a script on all server to collect user information (how many user account we have on all

Checking for installed packages and if not found install

I need to check for installed packages and if not installed install them. Example for RHEL, CentOS, Fedora: How do I do a check in BASH? Do I do something like? And what do I need to use for other distributions? apt-get? Answer Try the following code : or shorter : For debian likes : For archlinux :

Better bash script to create directory structure

I want to create folders with plain text with a structure like: I thought about using a base command like mkdir and found that post : Bash script that creates a directory structure, but it still needs to write structure like : So I would need to change the regex used in : What bash command could I use to

Reading username and password from file

I’m looking at a away of reading the username and password of a file and inputing those to either add user or delete user. EG: I have a file named ‘userlist’ with the following content with this format: What I don’t understand completely is how to use BASH script to add these accounts. What I have so far is this:

How to check if sed has changed a file

I am trying to find a clever way to figure out if the file passed to sed has been altered successfully or not. Basically, I want to know if the file has been changed or not without having to look at the file modification date. The reason why I need this is because I need to do some extra stuff

check if argument is a valid date in bash shell

I am writing a bash shell script in Linux, this program will accept a date (mm-dd-yyyy) as a parameter. I am wondering if there is a simply way to check if the date is valid? is there an operator and I can just use test to check? Answer You can check with date -d “datestring” So date -d “12/31/2012” is

Advertisement