Bash Shell Script: Command Line Foreach Loop

A quick code to demonstrate how you can make use of shell script foreach loop in command line to run any command repeatedly. [code language=”bash”] gunnalag@gmd:/u/gunnalag> foreach user ( `cat my-users.txt` ) foreach? ypmatch $user passwd >> my-users-ypmatch.txt foreach? end Can’t match key user9 in map passwd.byname. Reason: no such key in map. Can’t match key root in map passwd.byname. Reason: no such key in map. gunnalag@gmd:/u/gunnalag> [/code]

Read more

From Windows, how to remotely force logoff users on MAC OS X Systems (and/or) how to remotely find a process running as a given user and kill it on Unix systems

Have Cygwin Installed on your Windows System  to run any of your Unix commands.  Or you can directly run these commands from any of the Unix based systems Launch Cygwin shell command prompt. On Unix based system launch the terminal that runs the Bash Shell We use SSH to remotely execute the commands on Unix systems.  Whenever you run any SSH command, it’s prompt you to provide your password to remotely connect to the system. To avoid prompt/typing password have the SSH key infrastructure setup as detailed in  Automate command execution on MAC OS X/Unix Systems from Windows Systems remotely […]

Read more