BSD Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOperating SystemsBSD Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 7th, 2004, 04:23 AM
rei rei is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 13 rei User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 42 sec
Reputation Power: 0
ssh from shell script

i m trying to write a script which works as follow.
machine A , where my script is
machine B , the machine where i m trying to ssh

while in A, i'm trying to ssh B, and check if file test.c exist.
if exist, error msg will be displayed.

---------------------------------------------
ssh b.example.com
if [ -f /home/test.c ]; then
echo "file existing! " 1>&2
echo "Program terminating!" 1>&2
exit 1
fi
---------------------------------------------

but this alone is not working.
once i ssh, i'm considering entering machine B.
i would like the code below to work background in machine B, while i'm waiting for the result at machine A terminal.

may i know how i should code this?

Reply With Quote
  #2  
Old July 7th, 2004, 10:04 AM
icrf's Avatar
icrf icrf is offline
Perl Monkey
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: May 2003
Location: the far end of town where the Grickle-grass grows
Posts: 1,860 icrf User rank is Second Lieutenant (5000 - 10000 Reputation Level)icrf User rank is Second Lieutenant (5000 - 10000 Reputation Level)icrf User rank is Second Lieutenant (5000 - 10000 Reputation Level)icrf User rank is Second Lieutenant (5000 - 10000 Reputation Level)icrf User rank is Second Lieutenant (5000 - 10000 Reputation Level)icrf User rank is Second Lieutenant (5000 - 10000 Reputation Level)icrf User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 11 h 6 m
Reputation Power: 108
Send a message via AIM to icrf
can you put the code you want to run on machine B in a script and just call it with the -c switch to ssh? otherwise there's tools that can send info (Expect, maybe?) that you can look up and use
__________________
Andrew - Perl (and VB.NET) Monkey

Never underestimate the bandwidth of a hatchback full of tapes.

Reply With Quote
  #3  
Old July 7th, 2004, 10:27 PM
rei rei is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 13 rei User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 42 sec
Reputation Power: 0
Wink

Quote:
Originally Posted by icrf
can you put the code you want to run on machine B in a script and just call it with the -c switch to ssh? otherwise there's tools that can send info (Expect, maybe?) that you can look up and use


that is an idea too.
thanks.
i will try it out, but if the command i want to run in machine B is just one line or two, i hope that i do not need to script it.

by the way, i got the solutions as follow.
if ssh b.com ' [ -f file.c ] ' ; then
echo "error"

quote the command i want it to do with single quotations.


thanks for the idea

Reply With Quote
  #4  
Old April 14th, 2007, 10:45 PM
jvarodiya jvarodiya is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 1 jvarodiya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 17 sec
Reputation Power: 0
Quote:
Originally Posted by rei
that is an idea too.
thanks.
i will try it out, but if the command i want to run in machine B is just one line or two, i hope that i do not need to script it.

by the way, i got the solutions as follow.
if ssh b.com ' [ -f file.c ] ' ; then
echo "error"

quote the command i want it to do with single quotations.


thanks for the idea




Thanks for the code, this can be used for more more command with more condition.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsBSD Help > ssh from shell script

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap