Execute command from terminal on remote machine


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Execute command from terminal on remote machine
# 1  
Old 10-09-2007
Execute command from terminal on remote machine

Hi All,

I want to execute some commands on unix machine from the mac machne. I have two options for doing so, I am confused which is the best way of doing. Here are two options.

Requirement:
Execute command on the remote server machine. Commands to be executed itself contain arguments to be passed to some script.

Option1:
1. Perl script to do ssh and expect to connect to the remote machine and execute command over there.
Complexity/Overhead: If I need to execute any new command, I have to overwrite '.exp' file.

2. Use Net::SSH:Expect perl module to do so.
Complexity/Overhead: Bit difficult to install perl module on mac os. Smilie

I am confused here which is the best option which suite my requirement.

Will appreciate any guidance.

Thanks,
Ranu
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies

2. Shell Programming and Scripting

How can I execute local script on remote machine and include arguments?

I have a script in local server cd /home/dell/work/BOP/testdir ./processchk po (here processchk is a script & po is passed as an argument) Now I want to execute this script from remote server ssh $username@$hostname "cd /home/dell/work/BOP/testdir; ./processchk po" But Its getting error... (9 Replies)
Discussion started by: manohar2013
9 Replies

3. Shell Programming and Scripting

Execute shell script on remote machine

I want to execute a shell script(set of commands) on remote machine and that script takes input from text file(local machine). Please refer below: ssh user@hostname 'bash -s'< ./test.sh file.txt But i got the error file.txt doesn't exist. Can anyone help me on this. Content of test.sh: ... (2 Replies)
Discussion started by: manishtri88
2 Replies

4. UNIX for Dummies Questions & Answers

Execute shell script in remote machine

Hi All, We have 2 servers A and B. B is having a sctipt called b.sh in path /home/dev/scripts. Now my requirement is i want to execute b.sh from server A. Kindly help me. (3 Replies)
Discussion started by: Girish19
3 Replies

5. IP Networking

Execute script located on a remote machine

So, is there way of automating this ? My ultimate goal is to run some cmd script in windows and it should connect to a remote unix host and run a script x.sh located on the remote unix host. I was wanting to achieve this by using WinSCP and Putty only. If possible let me know how and if not... (25 Replies)
Discussion started by: mohtashims
25 Replies

6. Shell Programming and Scripting

Change user on remote machine and execute script!

Hi, I need to login into remote server and execute a shell script over there. As of now i am making use of ssh command ssh primUser@135.254.242.2 sh /poll.sh I am logging in as primUser but unless i change the user to root the script execution on the remote machine is not possible. ... (5 Replies)
Discussion started by: goutham4u
5 Replies

7. SCO

Execute command in remote

Hi, How to execute unix commands in remote unix servers? Thanks, Pintu (2 Replies)
Discussion started by: pintupatro
2 Replies

8. Shell Programming and Scripting

how to execute a script on remote machine

hi unix guru's i am new to unix shell programming. i found a trouble in executing a script(bali.ksh) which is available on serverA with username xyza, this script contains sqlplus command to retrive the data from the database available on other serverC. Now i need to run the above script... (4 Replies)
Discussion started by: balireddy_77
4 Replies

9. UNIX for Dummies Questions & Answers

execute a command in remote

how exec a command (ex. a cut or grep ) in anoter pc i have IP address, login and password. (another account of unix system) what's the sintax of command ??? es. my ip is 192.xx.xx.xx i make a exec of "ls" redirect in outpu file (> "file) in another pc ( ip 192.44.55.2xxx) (3 Replies)
Discussion started by: ZINGARO
3 Replies

10. UNIX for Dummies Questions & Answers

Plz Help : How to use write command to execute command on some other terminal

Hi Group , I m trying to execute commands on some other system using write command but inspite of executing the commands they r passed as simple messages. - i m writing >write user-id ! ls o ctrl-d inspite of executing the command ls,other terminal shows ! ls. Thnx in advance. (2 Replies)
Discussion started by: Aashish
2 Replies
Login or Register to Ask a Question
LSHG(1) 							    Lsh Manuals 							   LSHG(1)

NAME
lshg - secsh (SSH2) client SYNOPSIS
lshg [OPTION...] HOST [COMMAND] DESCRIPTION
CAUTION! The information in this manpage may be invalid or outdated. For authorative information on lsh, please see it's Texinfo manual (see the SEE ALSO section). Connects to the the remote machine HOST through a previously established lsh gateway and perform one or more actions, i.e. command execu- tion, various forwarding services. The default action is to start a remote interactive shell or execute a given command on the remote machine. OPTIONS
--debug Print huge amounts of debug information --log-file=File name Append messages to this file. -q, --quiet Suppress all warnings and diagnostic messages --trace Detailed trace -v, --verbose Verbose diagnostic messages --askpass=Program Program to use for reading passwords. Should be an absolute filename. -l, --user=User name Login as this user. -p, --port=Port Connect to this port. Actions: -B, --background Put process into the background. Implies -N. -D, --forward-socks[=port] Enable socks dynamic forwarding -E, --execute=command Execute a command on the remote machine -L, --forward-local-port=local-port:target-host:target-port -N, --nop No operation (suppresses the default action, which is to spawn a remote shell) --subsystem=subsystem-name Connect to given subsystem. Implies --no-pty. -S, --shell=command Spawn a remote shell Universal not: -n, --no Inverts the effect of the next modifier Modifiers that apply to port forwarding: -g, --remote-peers Allow remote access to forwarded ports --no-remote-peers Disallow remote access to forwarded ports (default). Modifiers that apply to remote execution: --detach Detach from terminal at session end. --no-detach Do not detach session at end, wait for all open channels (default). --no-pty Don't request a remote pty. --no-stderr Redirect stderr to /dev/null --no-stdin Redirect stdin from /dev/null --no-stdout Redirect stdout to /dev/null --stderr=Filename Redirect stderr --stdin=Filename Redirect stdin --stdout=Filename Redirect stdout -t, --pty Request a remote pty (default). Miscellaneous options: -e, --escape-char=Character Escape char. `none' means disable. Default is to use `~' if we have a tty, otherwise none. --write-pid Make -B write the pid of the backgrounded process to stdout. -G If no usable gateway is found, launch lsh instead. --send-debug=Message Send a debug message to the remote machine. --send-ignore=Message Send an ignore message to the remote machine. -?, --help Give this help list --usage Give a short usage message -V, --version Print program version Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options. DIAGNOSTICS
See the --verbose , --trace and --debug options. EXAMPLES
Using the -G option, for example in LSHGFLAGS it's easy to use an existing gateway if there is any and connect using lsh if not. REPORTING BUGS
Report bugs to <bug-lsh@gnu.org>. ENVIRONMENT
LSHG_FLAGS may be used for passing additional parameters. The parsing order is undefined. COPYING
The lsh suite of programs is distributed under the GNU General Public License; see the COPYING and AUTHORS files in the source distribution for details. AUTHOR
The lsh program suite is written mainly by Niels Moller <nisse@lysator.liu.se>. This man-page was written for lsh 2.0 by Pontus Freyhult <pont_lsh@soua.net>, it is based on a template written by J.H.M. Dassen (Ray) <jdassen@wi.LeidenUniv.nl>. SEE ALSO
lsftp(1), lsh(1), lsh-authorize(1), lsh-export-key(1), lsh-keygen(1), lsh-make-seed(1), lsh-upgrade(1), lsh-upgrade-key(1), lsh- writekey(1), lshd(8), ssh-conv(1) The full documentation for lsh is maintained as a Texinfo manual. If the info and lsh programs are properly installed at your site, the command info lsh should give you access to the complete manual. LSHG
NOVEMBER 2004 LSHG(1)