rsh and rexec commands (inbuilt) and we can use PsExec.exe
RSH:
---
Runs commands on remote hosts running the RSH service.
RSH host [-l username] [-n] command
host Specifies the remote host on which to run command.
-l username Specifies the user name to use on the remote host. If
omitted, the logged on user name is used.
-n Redirects the input of RSH to NULL.
command Specifies the command to run.
Rexex:
------
Runs commands on remote hosts running the REXEC service. Rexec
authenticates the user name on the remote host before executing the
specified command.
REXEC host [-l username] [-n] command
host Specifies the remote host on which to run command.
-l username Specifies the user name on the remote host.
-n Redirects the input of REXEC to NULL.
command Specifies the command to run.
Myself (Sravan Kumar E) Datacenter and Cloud Computing Professional with over 14+ years of experience, including service leadership and management of mid to large size organization, corporate development, Product Implementation, Cloud Scoping and Implementation,business,operations and strategy.
Advertisement Header
Thursday, 12 August 2010
Wednesday, 28 July 2010
How to Run Multiple commands Remotely Using Script in Linux/Unix
#!/bin/bash
# Linux/UNIX box with ssh key based login
SERVERS="Server1 server2 server3"
# SSH User name
USR="Admin"
# Email
SUBJECT="Server user login report"
EMAIL="sravan03ie29@hotmail.com"
EMAILMESSAGE="/tmp/emailmessage.txt"
# create new file
>$EMAILMESSAGE
# connect each host and pull up user listing
for host in $SERVERS
do
echo "--------------------------------" >>$EMAILMESSAGE
echo "* HOST: $host " >>$EMAILMESSAGE
echo "--------------------------------" >>$EMAILMESSAGE
sudo ssh $USR@$host " hostname; df -h" >> $EMAILMESSAGE
done
# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
# Linux/UNIX box with ssh key based login
SERVERS="Server1 server2 server3"
# SSH User name
USR="Admin"
SUBJECT="Server user login report"
EMAIL="sravan03ie29@hotmail.com"
EMAILMESSAGE="/tmp/emailmessage.txt"
# create new file
>$EMAILMESSAGE
# connect each host and pull up user listing
for host in $SERVERS
do
echo "--------------------------------" >>$EMAILMESSAGE
echo "* HOST: $host " >>$EMAILMESSAGE
echo "--------------------------------" >>$EMAILMESSAGE
sudo ssh $USR@$host " hostname; df -h" >> $EMAILMESSAGE
done
# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
Tuesday, 6 July 2010
Loop Processing in Powershell
For Loop:
for ($i=1; $i -le 5; $i++)
{Write-Host $i}
Output:
1
2
3
4
5
------------------------------
$i=1
for (; $i -le 5; $i++)
{Write-Host $i}
------------------------------
$ints = @( 1, 2, 3, 4, 5)
for ($i=0; $i -le $ints.Length – 1; $i++)
{Write-Host $ints[$i]}
------------------------------
Foreach:
$ints = @(1, 2, 3, 4, 5)
foreach ($i in $ints)
{Write-Host $i}
Output:
1
2
3
4
5
-----------------------------
for($i=1; $i -le 10; $i++)
{
Write-Host $i
break
}
-----------------------------
$i=0
$varB = (10,20,30,40)
foreach ($var in $varB)
{
$i++
if ($var -eq 30)
{
break
}
}
Write-Host “30 was found in array position $i”
------------------------------
for ($i=1; $i -le 5; $i++)
{Write-Host $i}
Output:
1
2
3
4
5
------------------------------
$i=1
for (; $i -le 5; $i++)
{Write-Host $i}
------------------------------
$ints = @( 1, 2, 3, 4, 5)
for ($i=0; $i -le $ints.Length – 1; $i++)
{Write-Host $ints[$i]}
------------------------------
Foreach:
$ints = @(1, 2, 3, 4, 5)
foreach ($i in $ints)
{Write-Host $i}
Output:
1
2
3
4
5
-----------------------------
for($i=1; $i -le 10; $i++)
{
Write-Host $i
break
}
-----------------------------
$i=0
$varB = (10,20,30,40)
foreach ($var in $varB)
{
$i++
if ($var -eq 30)
{
break
}
}
Write-Host “30 was found in array position $i”
------------------------------
Subscribe to:
Posts (Atom)