how to debug an expect script running on a tomcat server


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to debug an expect script running on a tomcat server
# 1  
Old 11-25-2010
Question how to debug an expect script running on a tomcat server

Hello everyone,

I have a small expect script as follows;
Code:
#!/usr/bin/expect -f
set force_conservative 0  ;# set to 1 to force conservative mode even if
              ;# script wasn't run conservatively originally
if {$force_conservative} {
    set send_slow {1 .1}
    proc send {ignore arg} {
        sleep .1
        exp_send -s -- $arg
    }
}
set timeout -1
spawn /bin/bash
match_max 100000
send -- "su randeel\r"
expect -exact "su randeel\r
Password: "
send -- "some password\r"
expect "randeel@"
send -- "wine cmd /c wscript Z:\\\\tmp\\\\tomcat6-temp\\\\3fe21de5ca0fe5fb.vbs"
expect -exact "wine cmd /c wscript Z:\\\\tmp\\\\tomcat6-temp\\\\3fe21de5ca0fe5fb.vbs"
send -- "\r"
expect "IRemUnknown_RemRelease"
expect "IRemUnknown_RemRelease"
expect "IRemUnknown_RemRelease"
send -- "\r"
exit
expect eof


when i run this script as another user the above works great!!
But when i invoke the above script from tomcat server(using a java programme to execute the script) as user "tomcat6"
the script doesn't execute fully. How can i debug this issue?
when i issue the command ps -ef;
I see that tomcat6 user has called the script and the process is running.
i also see the bash command also invoked, also i see "su randeel" command also being running.
But i don't know how to debug this issue. I am new to expect,ubuntu.
Any kind of help would be appreciated.

Thank you,
Randeel.

Last edited by radoulov; 11-25-2010 at 06:17 PM.. Reason: Code tags, please!
# 2  
Old 11-26-2010
If all else fails, you can truss, tusc or strace the tomcat process as it get the service call that runs expect, to see where it stops. Use a realistic timeout, and it may tell you where it hung.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Transfer file from server B to server C and running the script on server A

I have 3 servers A, B, C and server B is having some files in /u01/soa/ directory, these files i want to copy to server C, and i want to run the script from server A. Script(Server A) --> Files at Server B (Source server) --> Copy the files to Server C(Target Server). We dont have RSA key... (4 Replies)
Discussion started by: kiran_j
4 Replies

2. Shell Programming and Scripting

Expect Script not running from cron. Full Paths used

My cron file. Copied $PATH # Minute Hour Day of Month Month Day of Week Command SHELL=/bin/ksh PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/perl/lib:/perl/lib/lib/perl5:/perl/scripts:.:/perl/lib/local:/home/popeye:/temp 0... (3 Replies)
Discussion started by: popeye
3 Replies

3. Shell Programming and Scripting

Expect script cronjob running but dying prematurely

I have an Ubuntu machine that I'd like to update automatically. I've written an expect script to run the aptitude package manager and update my packages. Essentially it does: aptitude update && aptitude upgrade while answering "yes" at the appropriate time. It works quite nicely when run... (4 Replies)
Discussion started by: CluelessPerson
4 Replies

4. Shell Programming and Scripting

Debug script already running

Hello, is it possible to debug a script that is already running "on-demand"? Somehow a command like "set -x" but once you've executed the script. And another one to disable debugging? Thank you (0 Replies)
Discussion started by: asanchez
0 Replies

5. Programming

Is there any possibility of running the PHP script in a debug mode ?

Is there any possibility of running the PHP script in a debug mode ? If so, do i have to download any package? Any free downloads available? Can anyone please guide me through? Am a newbie in PHP scripting. Thanks in Advance! (1 Reply)
Discussion started by: vidhyaS
1 Replies

6. Programming

Expect script to run a Shell script on remote server

Hi All, I am using a expect script to run a shell script on remote server, the code is as follows. But the problem is that it executes only first command, and hangs it doesn't run the next commands. spawn ssh $uid@$host expect "password:" send "$password\r" expect "*\r" send... (2 Replies)
Discussion started by: yashwanthsn
2 Replies

7. Shell Programming and Scripting

Expect debug output

Hi! I want to start OO in headless mode via expect - the oo command would be su - root -c "/usr/lib/openoffice/program/soffice -headless -nofirststartwizard -norestore -nolockcheck -nocrashreport -nodefault -accept='socket,host=0.0.0.0,port=8100;urp;StarOffice.Service'" and the expect... (2 Replies)
Discussion started by: senior.weber
2 Replies

8. Programming

Need a little help in running jsp pages(Tomcat server).

Hi, I have installed following software on my linux machine. Is there anything else required to run jsp pages on linux machine? Please Help Here are some details that might be helpful. # lsb_release -a LSB Version: ... (3 Replies)
Discussion started by: pinga123
3 Replies

9. Shell Programming and Scripting

How to write an expect script to check if a process is running?

I'm new to expecting and i want to create a script to ssh to a device,check is a process is running and display that the process is running or not.This is what i have so far After executing this script i get an error. #!/usr/bin/expect set timeout -1 set ip "machine ip goes here" set... (5 Replies)
Discussion started by: icchi
5 Replies

10. Linux

jsp not working on linux running tomcat server

hey there we cant seem to get jsp to load pages properly on linux running tomcat 4 server. everytime we run .jsp files, the source code comes up instead of the actual file contents. any suggestions?? cheers mile1982 (1 Reply)
Discussion started by: mile1982
1 Replies
Login or Register to Ask a Question