Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Expect from Program

 
Sree Potluri
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sree Potluri
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am working in Windows NT but trying to run Expect commands
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic