Sponsored Content
Top Forums Shell Programming and Scripting Need help with executing multiple commands in remote machine Post 302490837 by ajayakunuri on Tuesday 25th of January 2011 08:46:33 PM
Old 01-25-2011
Need help with executing multiple commands in remote machine

Hi,
I work on a jumpserver and I wrote a script to transfer a file from source server to destination server.
Code:
#!/bin/ksh
echo "\nEnter the file name:\n"
read name
echo "\nSelect the Source server\n"
echo "1.  ODS PROD "
echo "2.  ODS DROPBOX"
echo "3.  ODS STE"
echo "4.  ODS STE DROPBOX"
echo "5.  ODS CTE "
echo "6.  ODS CTE DROPBOX"
echo "7.  ODS ITE"
echo "8.  ODS ITE DROPBOX"
echo "9.  ODS DEV"
echo "10. ODS DEV DROPBOX"
echo "11. ODS Legacy Prod"
echo "12. EXIT"
read optn
echo "\nSelect the path\n"
read path
case $optn in
  1) scp `whoami`@162.111.210.43:$path/$name .;;
         2) scp `whoami`@162.111.214.23:$path/$name .;;
        3) scp `whoami`@167.138.250.239:$path/$name .;;
        4) scp `whoami`@167.138.250.224:$path/$name .;;
        5) scp `whoami`@172.21.207.158:$path/$name .;;
        6) scp `whoami`@172.21.220.162:$path/$name .;;
        7) scp `whoami`@172.21.207.72:$path/$name .;;
        8) scp `whoami`@172.21.220.18:$path/$name .;;
         9) scp `whoami`@172.18.197.41:$path/$name .;;
        10) scp `whoami`@172.18.197.43:$path/$name .;;
         11) scp `whoami`@170.13.54.102:$path/$name .;;
 
 
esac
chmod 777 $name
echo "\nSelect the dest server\n"
echo "1.  ODS PROD "
echo "2.  ODS DROPBOX"
echo "3.  ODS STE"
echo "4.  ODS STE DROPBOX"
echo "5.  ODS CTE "
echo "6.  ODS CTE DROPBOX"
echo "7.  ODS ITE"
echo "8.  ODS ITE DROPBOX"
echo "9.  ODS DEV"
echo "10. ODS DEV DROPBOX"
echo "11. ODS Legacy Prod"
echo "12. EXIT"
read optn2
echo "\nSelect the destination path\n"
read destpath
case $optn2 in 
 1) scp $name `whoami`@162.111.210.43:/home/`whoami`;;
 2) scp $name `whoami`@162.111.214.23:/home/`whoami`;;
 3) scp $name `whoami`@167.138.250.239:/home/`whoami`;;
 4) scp $name `whoami`@167.138.250.224:/home/`whoami`;;
 5) scp $name `whoami`@172.21.207.158:/home/`whoami`;;
 6) scp $name `whoami`@172.21.220.162:/home/`whoami`;;
 7) scp $name `whoami`@172.21.207.72:/home/`whoami`;;
 8) scp $name `whoami`@172.21.220.18:/home/`whoami`;;
 9) scp $name `whoami`@172.18.197.41:/home/`whoami`;;
 10) scp $name `whoami`@172.18.197.43:/home/`whoami`;;
        11) scp $name `whoami`@170.13.54.102:/home/`whoami`;;
        12) exit;;
esac
 
case $optn2 in 
 #9) ssh -l x772525 172.18.197.41 'su - d_od; cd /home/x772525;chmod 777 $name;cp -p $name $destpath;';;
 9) ssh 172.18.197.41 "cd /home/x772525;chmod 777 $name;cp -p $name $destpath"
 
esac

the whole thing is executing fine, but at the end when i use su - d_od, it is giving me the following error:
Must be attached to terminal for 'am I' option
stty: : Invalid argument

I need to change the permissions of the file using d_od. Can someone please help me with this?

Thanks
Ajay
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to stay in remote shell after executing commands in ssh?

the ssh calling convention: ssh <server> If I put commands in the section, ssh will execute them immediately after logging in and return to local shell. I want to stay in the remote shell after executing these commands. How can I achieve this? Thanks for all. (1 Reply)
Discussion started by: hplonlien
1 Replies

2. Solaris

Help with executing multiple remote commands after multiple hops

Hi SSHers, I have embedded this below code in my shell script.. /usr/bin/ssh -t $USER@$SERVER1 /usr/bin/ssh $USER2@S$SERVER2 echo uptime:`/opt/OV/bin/snmpget -r 0 -t 60 $nodeName system.3.0 | cut -d: -f3-5` SSH to both these servers are public-key authenticated, so things run... (13 Replies)
Discussion started by: LinuxUser2008
13 Replies

3. Shell Programming and Scripting

executing command in a remote machine through ssh - shell script

Hi All, i have two machines like x and y . my requirement is i should connect to machine Y from x through ssh connection . and do some operation such as copy and move and delete files in Y machine . i tried with this code but it is doing in machine x only . and i need to exit from Y when... (1 Reply)
Discussion started by: rateeshkumar
1 Replies

4. Shell Programming and Scripting

executing commands in remote server using ssh

I have some commands which need to be executed in remote machine. I have Linux Server from where I need to connect to Solaris server using ssh and then declare some variable over there and run some commands. I don't want to call a script which is present in Solaris server from Linux server... (7 Replies)
Discussion started by: maitree
7 Replies

5. Linux

send remote commands to windows machine?

hey guys, I've done some searching and other than winexe I haven't been able to find a way to send remote commands to a windows machine. The problem I get is with winexe whenever you send the process to the background in a script, I get the following error. :wall: Any help is appreciated! ... (0 Replies)
Discussion started by: terrell
0 Replies

6. Shell Programming and Scripting

Executing remote commands via ssh

Hi, I'm tryin to write a script that will collect information about a remote servers, put them into variables and print them to screen. # /usr/bin/bash ls $1 > /dev/null 2>/dev/null if then echo "$1 is file" for server in $(cat $1) do # echo $server ... (5 Replies)
Discussion started by: moshesa
5 Replies

7. Shell Programming and Scripting

Executing multiple commands in a file at same time

Hi Am having file.ksh as below wc -l file1.txt wc -l file2.txt wc -l file3.txt wc -l file4.txt i want all the commands in this file to execute in same time please help Thanks in advance (1 Reply)
Discussion started by: ragu.selvaraj
1 Replies

8. Linux

Executing a script in remote machine through ssh

How to execute a script in remote machine through ssh I have a script test.sh which does some backup activity in remote machine. Wanted to keep backup also in remote machine. ssh -l username <remote machine> "commands to be exceuted as ; separted" but how to put the script in the place of... (5 Replies)
Discussion started by: sanvel
5 Replies

9. UNIX for Dummies Questions & Answers

How to run UNIX commands on remote machine from windows?

Hi All, I am working in support and we are planning to automate a system to reduce the direct manual intervention to core system. Please find the below details. 1. we have a web application that runs on Windows Platform. 2. From web application, we need to connect to remote Unix machine.... (6 Replies)
Discussion started by: Balaji K
6 Replies

10. Shell Programming and Scripting

Login to remote machine pass commands and capture all in a file

Dear user/friends, After a long gap of 6 years i am back to this forum to find a solution and i hope i will get a solution or atleast a workaround for the problem:p Following is my task which i am trying for almost 3 days without any success. 1) run this command from my terminal (note i... (7 Replies)
Discussion started by: imas
7 Replies
vino-server(1)							   User Commands						    vino-server(1)

NAME
vino-server - remote desktop server SYNOPSIS
vino-server DESCRIPTION
vino-server is a remote desktop server based on VNC protocol. vino-server provides remote desktop takeover and remote desktop view func- tions. vino-server allows multiple client to access a GNOME desktop session remotely. It is based on the VNC technology. vino-server pro- vides service at port 5800. Each desktop has a vino server which disabled by default and a Java client application which is made available to a client via a web browser (via port 5900 of the server machine is the service is enabled by the user). FILES
The following files are used by this application: /usr/lib/vino-server The executable file for the vino server application. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWgnome-remote-desktop | +-----------------------------+-----------------------------+ |Interface stability |Volatile | +-----------------------------+-----------------------------+ SEE ALSO
vino-passwd(1), vino-preferences(1), attributes(5) NOTES
Written by Steven Zhang, Sun Microsystems Inc., 2006. Updated by Halton Huo, Sun Microsystems Inc., 2008. SunOS 5.11 15 Aug 2008 vino-server(1)
All times are GMT -4. The time now is 05:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy