You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Bradberry, Rick" <rb...@exchange.DAYTONOH.NCR.com> on 2003/08/02 16:23:51 UTC

RE: Running external C routine from a servlet ? Please help me !! !!

Michel,

I had a similar problem creating files in a servlet. I found that in my
case, the relative
path start in the directory where tomcat is started. I changed the startup
script to do a
cd to $tomcat_home then called bin/startup.sh.

Hope this helps

Rick Bradberry
NCR WCS Managed Services 
Telephone: 937-848-2203
Cell Phone: 937-367-1879
efax: 413-674-7094


-----Original Message-----
From: Michel Jubault [mailto:michel.jubault@free.fr]
Sent: Saturday, August 02, 2003 9:45 AM
To: tomcat-user@jakarta.apache.org
Subject: Running external C routine from a servlet ? Please help me !!!!


Hi there !

I'm running a little C program from a servlet. I'm using runtime, process
and exec to do this. I gather the result in an inputstream. In fact there's
no pb on that.
The problem is rather a path problem. All servlets in my app are using
relative path to found the others and properties file ie the working
directory is myapp/WEB-INF/classes. But for C program the default path is
always the home path ie /root or /home/user.
I must build the complete absolute path to launch my C routine. I don't
understand why the default path isn't the classes path as for servlet.
I'm running under linux Red HAT 7.3, java 1.4.1_02, Tomcat 4.1.24.

Is there any config  file to modify in tomcat, linux or java?

Please help !

Many thanks in advance !

Michel



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org

Re: Running external C routine from a servlet ? Please help me !!!!

Posted by Michel Jubault <mi...@free.fr>.
Hi !
Many thanks, it's a good idea !!!
You're right it's the same case for me : the default dir is the directory
where I launch tomcat!!!!
Is it a particar behavior of the 4.1.24 version?

Regards

Michel

----- Original Message -----
From: Bradberry, Rick <rb...@exchange.DAYTONOH.NCR.com>
To: 'Tomcat Users List' <to...@jakarta.apache.org>
Sent: Saturday, August 02, 2003 4:23 PM
Subject: RE: Running external C routine from a servlet ? Please help me !!!!


> Michel,
>
> I had a similar problem creating files in a servlet. I found that in my
> case, the relative
> path start in the directory where tomcat is started. I changed the startup
> script to do a
> cd to $tomcat_home then called bin/startup.sh.
>
> Hope this helps
>
> Rick Bradberry
> NCR WCS Managed Services
> Telephone: 937-848-2203
> Cell Phone: 937-367-1879
> efax: 413-674-7094
>
>
> -----Original Message-----
> From: Michel Jubault [mailto:michel.jubault@free.fr]
> Sent: Saturday, August 02, 2003 9:45 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Running external C routine from a servlet ? Please help me !!!!
>
>
> Hi there !
>
> I'm running a little C program from a servlet. I'm using runtime, process
> and exec to do this. I gather the result in an inputstream. In fact
there's
> no pb on that.
> The problem is rather a path problem. All servlets in my app are using
> relative path to found the others and properties file ie the working
> directory is myapp/WEB-INF/classes. But for C program the default path is
> always the home path ie /root or /home/user.
> I must build the complete absolute path to launch my C routine. I don't
> understand why the default path isn't the classes path as for servlet.
> I'm running under linux Red HAT 7.3, java 1.4.1_02, Tomcat 4.1.24.
>
> Is there any config  file to modify in tomcat, linux or java?
>
> Please help !
>
> Many thanks in advance !
>
> Michel
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Running external C routine from a servlet ? The solution...

Posted by Michel Jubault <mi...@free.fr>.
Hi Rick !

I've found a better way to precise the default directory for a particular
subprocess :
rather than using : exec(String command) to launch your process,
use : exec (String command, null, File directory) where directory is the
default dir for your external routine !!
It's working well for me !!

For building a near relative path to save files, I'v found :
String external_dir_path = System.getProperty("catalina.home") +
 System.getProperty("file.separator") + "webapps" +
 System.getProperty("file.separator") + "myapp" +
 System.getProperty("file.separator") + "WEB-INF" +
 System.getProperty("file.separator") + "classes" +
 System.getProperty("file.separator") + "external" +   <------- or whatever
you want !!
 System.getProperty("file.separator");
Yes, it's relative to tomcat home, but it's better than absolute path !!!!
It makes your webapp easier to adapt to another system (other server, linux,
windows,...).

Thanks again for your help !
Regards
Michel


----- Original Message -----
From: Bradberry, Rick <rb...@exchange.DAYTONOH.NCR.com>
To: 'Tomcat Users List' <to...@jakarta.apache.org>
Sent: Saturday, August 02, 2003 4:23 PM
Subject: RE: Running external C routine from a servlet ? Please help me !!!!


> Michel,
>
> I had a similar problem creating files in a servlet. I found that in my
> case, the relative
> path start in the directory where tomcat is started. I changed the startup
> script to do a
> cd to $tomcat_home then called bin/startup.sh.
>
> Hope this helps
>
> Rick Bradberry
> NCR WCS Managed Services
> Telephone: 937-848-2203
> Cell Phone: 937-367-1879
> efax: 413-674-7094
>
>
> -----Original Message-----
> From: Michel Jubault [mailto:michel.jubault@free.fr]
> Sent: Saturday, August 02, 2003 9:45 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Running external C routine from a servlet ? Please help me !!!!
>
>
> Hi there !
>
> I'm running a little C program from a servlet. I'm using runtime, process
> and exec to do this. I gather the result in an inputstream. In fact
there's
> no pb on that.
> The problem is rather a path problem. All servlets in my app are using
> relative path to found the others and properties file ie the working
> directory is myapp/WEB-INF/classes. But for C program the default path is
> always the home path ie /root or /home/user.
> I must build the complete absolute path to launch my C routine. I don't
> understand why the default path isn't the classes path as for servlet.
> I'm running under linux Red HAT 7.3, java 1.4.1_02, Tomcat 4.1.24.
>
> Is there any config  file to modify in tomcat, linux or java?
>
> Please help !
>
> Many thanks in advance !
>
> Michel
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Running external C routine from a servlet ? The solution...

Posted by Michel Jubault <mi...@free.fr>.
Hi Rick !

I've found a better way to precise the default directory for a particular
subprocess :
rather than using : exec(String command) to launch your process,
use : exec (String command, null, File directory) where directory is the
default dir for your external routine !!
It's working well for me !!

For building a near relative path to save files, I'v found :
String external_dir_path = System.getProperty("catalina.home") +
 System.getProperty("file.separator") + "webapps" +
 System.getProperty("file.separator") + "myapp" +
 System.getProperty("file.separator") + "WEB-INF" +
 System.getProperty("file.separator") + "classes" +
 System.getProperty("file.separator") + "external" +   <------- or whatever
you want !!
 System.getProperty("file.separator");
Yes, it's relative to tomcat home, but it's better than absolute path !!!!
It makes your webapp easier to adapt to another system (other server, linux,
windows,...).

Thanks again for your help !
Regards
Michel


----- Original Message -----
From: Bradberry, Rick <rb...@exchange.DAYTONOH.NCR.com>
To: 'Tomcat Users List' <to...@jakarta.apache.org>
Sent: Saturday, August 02, 2003 4:23 PM
Subject: RE: Running external C routine from a servlet ? Please help me !!!!


> Michel,
>
> I had a similar problem creating files in a servlet. I found that in my
> case, the relative
> path start in the directory where tomcat is started. I changed the startup
> script to do a
> cd to $tomcat_home then called bin/startup.sh.
>
> Hope this helps
>
> Rick Bradberry
> NCR WCS Managed Services
> Telephone: 937-848-2203
> Cell Phone: 937-367-1879
> efax: 413-674-7094
>
>
> -----Original Message-----
> From: Michel Jubault [mailto:michel.jubault@free.fr]
> Sent: Saturday, August 02, 2003 9:45 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Running external C routine from a servlet ? Please help me !!!!
>
>
> Hi there !
>
> I'm running a little C program from a servlet. I'm using runtime, process
> and exec to do this. I gather the result in an inputstream. In fact
there's
> no pb on that.
> The problem is rather a path problem. All servlets in my app are using
> relative path to found the others and properties file ie the working
> directory is myapp/WEB-INF/classes. But for C program the default path is
> always the home path ie /root or /home/user.
> I must build the complete absolute path to launch my C routine. I don't
> understand why the default path isn't the classes path as for servlet.
> I'm running under linux Red HAT 7.3, java 1.4.1_02, Tomcat 4.1.24.
>
> Is there any config  file to modify in tomcat, linux or java?
>
> Please help !
>
> Many thanks in advance !
>
> Michel
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>


Re: Running external C routine from a servlet ? Please help me !!!!

Posted by Michel Jubault <mi...@free.fr>.
Hi !
Many thanks, it's a good idea !!!
You're right it's the same case for me : the default dir is the directory
where I launch tomcat!!!!
Is it a particar behavior of the 4.1.24 version?

Regards

Michel

----- Original Message -----
From: Bradberry, Rick <rb...@exchange.DAYTONOH.NCR.com>
To: 'Tomcat Users List' <to...@jakarta.apache.org>
Sent: Saturday, August 02, 2003 4:23 PM
Subject: RE: Running external C routine from a servlet ? Please help me !!!!


> Michel,
>
> I had a similar problem creating files in a servlet. I found that in my
> case, the relative
> path start in the directory where tomcat is started. I changed the startup
> script to do a
> cd to $tomcat_home then called bin/startup.sh.
>
> Hope this helps
>
> Rick Bradberry
> NCR WCS Managed Services
> Telephone: 937-848-2203
> Cell Phone: 937-367-1879
> efax: 413-674-7094
>
>
> -----Original Message-----
> From: Michel Jubault [mailto:michel.jubault@free.fr]
> Sent: Saturday, August 02, 2003 9:45 AM
> To: tomcat-user@jakarta.apache.org
> Subject: Running external C routine from a servlet ? Please help me !!!!
>
>
> Hi there !
>
> I'm running a little C program from a servlet. I'm using runtime, process
> and exec to do this. I gather the result in an inputstream. In fact
there's
> no pb on that.
> The problem is rather a path problem. All servlets in my app are using
> relative path to found the others and properties file ie the working
> directory is myapp/WEB-INF/classes. But for C program the default path is
> always the home path ie /root or /home/user.
> I must build the complete absolute path to launch my C routine. I don't
> understand why the default path isn't the classes path as for servlet.
> I'm running under linux Red HAT 7.3, java 1.4.1_02, Tomcat 4.1.24.
>
> Is there any config  file to modify in tomcat, linux or java?
>
> Please help !
>
> Many thanks in advance !
>
> Michel
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>