The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Expect program with password as arg illcar Shell Programming and Scripting 1 01-30-2009 08:04 PM
strange expect script behavior, or am i misunderstanding expect scripting? v1k0d3n Shell Programming and Scripting 2 12-10-2008 04:31 PM
Script to open program and send/execute command in program tuathan UNIX for Dummies Questions & Answers 1 11-19-2008 09:59 PM
how to execute this program? sathyaac Shell Programming and Scripting 1 06-27-2008 08:31 AM
execve to execute a program winsonlee High Level Programming 0 07-25-2004 05:18 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-10-2009
fozay fozay is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 13
How to execute a program at expect script

what i need is that after passwordless enter another program should execute. I can succeed passwordless login but ı could not execute (./son) program. pls help me
  #2 (permalink)  
Old 07-10-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,285
Did you read any of the many guides and howtos? I bet there is somewhere an example how to execute a program after login. Post what you got so far, ty.
  #3 (permalink)  
Old 07-10-2009
ryandegreat25 ryandegreat25 is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 236
Try using ssh

ssh -l $UserName $RemoteHost command
  #4 (permalink)  
Old 07-10-2009
fozay fozay is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 13
I want at expect script to execute another program for example:

#!/usr/local/bin/expect

spawn ssh root@172.30.64.163

expect "login:"
send "root\n"
expect "password:"
send "root\n"

send "./son" ----it does not work instead of this what should i write

interact
  #5 (permalink)  
Old 07-10-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,285
Use CODE-tags when posting code, data or logs for better readability and to keep formatting/indention etc, ty.

Is "son" available on the destination machine?
What is the error you get?..
  #6 (permalink)  
Old 07-10-2009
fozay fozay is offline
Registered User
  
 

Join Date: Jul 2009
Posts: 13
"son" is available on the dest. machine. I dont get an error because the duty of send is writing what you write inside the " ". So it is printing ./son on the screen but it dont execute it.
  #7 (permalink)  
Old 07-10-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,285
I am not using expect but having a short look into some tutorial I saw they often use \r when sending commands which looks like a enter stroke or something, like
Code:
send "./son\r"
If still nothing gets executed maybe try to add an "exec" inside the quotes in front of "son\r".

Check this
DeBaan: Simple expect ssh example
or any other of the 32.800.000 hits you get when you google for "expect tutorial".
Reply

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0