GeeCON Prague 2014*
The moose likes General Computing and the fly likes Expect from Program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » General Computing
Bookmark "Expect from Program" Watch "Expect from Program" New topic
Author

Expect from Program

Sree Potluri
Ranch Hand

Joined: Aug 12, 2009
Posts: 62
Hi,

I am new to working with Linux/Unix. I created a file which executes set of expect commands. It works fine, when I am running it from command prompt. I have written a program that executes series of commands using the program test.expect.

I am using java 1.7, expect 5.1 and Windows NT system.

I am trying to run the commands from program using



This is creating a text file, but it has no values.
Can some one help me. I am trying to run set of commands.

I tried another approach, where I created a batch file and processing the batch file, but the problem is that, the command takes 50sec to execute and all the commands are not executing.

Please help me.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Um, you can't pass Windows command to Linux. Well, you can (you obviously are), but they won't work. Try using the Linux equivalents.

But I think I am confused. You said this:
I am new to working with Linux/Unix.

And then this:
I am using ... Windows NT system.

So which is it? Are you running Linux or Windows NT? If the latter, this is the wrong forum and I will move the post for you.

JBoss In Action
Sree Potluri
Ranch Hand

Joined: Aug 12, 2009
Posts: 62
I am working in Windows NT but trying to run Expect commands
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Aside form the syntax error is the code you posted (the extra " right after >> on line 4), I suspect that "expect" outputs information to stderr and not to stdout. So try also redirecting stderr:

p = rt.exec("cmd /c expect a b >> c:/test.txt 2>&1");

Also, since this has nothing to do with Linux, I'll move this post to a more appropriate location.
 
GeeCON Prague 2014
 
subject: Expect from Program