ssh/bash script question

This is a discussion on ssh/bash script question within the Tech Board forums, part of the Community Boards category; I'm trying to log into a remote server and get the uname every 5 minutes. However, I can't get it ...

  1. #1
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329

    ssh/bash script question

    I'm trying to log into a remote server and get the uname every 5 minutes. However, I can't get it work. Here is what I attempted

    [cd@localhost ~]$ ssh -T cd@eecs.berkeley.edu uname;sleep 2;uname
    cd@eecs.berkeley.edu's password:
    FreeBSD
    Linux
    [cd@localhost ~]$

    One the first pass, I get 'FreeBSD', which is the remote servers uname. However, on the second pass I get 'Linux', which is my local host and not the remote host. Can I pass some kind of crude loop construct at the ssh command line?

  2. #2
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    semicolon ends a command. You're telling bash to ssh in and execute uname. Then that process ends and you execute sleep 2 locally, then uname locally.

    try:
    ssh -T cd@eecs.berkeley.edu "uname;sleep 2;uname"

  3. #3
    Banned
    Join Date
    May 2007
    Location
    Berkeley, CA
    Posts
    329
    Yeah, that was what I was looking for. Thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 04-10-2009, 01:57 AM
  2. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 01:14 PM
  3. proxy.pac (proxy auto config) question
    By boreder in forum C Programming
    Replies: 2
    Last Post: 01-20-2009, 03:13 AM
  4. php script question (is this possible?)
    By Leeman_s in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 12-30-2003, 09:20 PM
  5. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 10:47 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21