Thread: ssh/bash script question

  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 [email protected] uname;sleep 2;uname
    [email protected]'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 [email protected] "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, 12:57 AM
  2. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12: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, 09:47 PM