• Post Reply Bookmark Topic Watch Topic
  • New Topic

php + awk for jsp  RSS feed

 
Brendan Kennedy
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have a test php program that I want to write in jsp as follows :

It checks whether a user logged into my server has accessed my webpage. Is the only way to do this in jsp is to write a script and use 'Process p = Runtime.getRuntime().exec("check_usr.sh");'
instead of using echo or finger or whetever other system call I want from within the jsp?
Thanks,
Brendan
 
Shawn Bayern
Author
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Brendan Kennedy:
Hello,
I have a test php program that I want to write in jsp as follows :

It checks whether a user logged into my server has accessed my webpage. Is the only way to do this in jsp is to write a script and use 'Process p = Runtime.getRuntime().exec("check_usr.sh");'
instead of using echo or finger or whetever other system call I want from within the jsp?
Thanks,
Brendan

Howdy, Brendan. Any chance you're the same Brendan Kennedy I know from Yale?
Anyhow, there's no portable way to gather high-level system information (like that from finger and so forth) from a Java or JSP program. The text processing -- that is, the stuff you're doing with 'cut' and 'awk' -- is easily replicable in Java, either by using the core class libraries (java.lang.String, java.util.StringTokenizer), but the raw data that I think you're looking for comes either from system-specific files (e.g, /var/adm/utmpx) or from in-memory OS structures (in the case, for example, of system information vended via /proc on a Linux machine).
Still, depending precisely on the information you're looking for (and I can't tell that entirely from the script you posted), it might be possible to read a file from a well-known location in a well-known format and parse it.
 
Brendan Kennedy
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"You sir, have the boorish manner of a Yaley!"
(Sideshow Bob)
nah - I was in Chicago once, but I live in Dublin Ireland(and go to DCU).
hmm, looks like php has one up on jsp there in my book. Of course(just though of this now) I can run the php from my jsp using the runtime thing cos it can be run from the command line)...might have to setfacl the script though..
Thanks,
Brendan
 
Shawn Bayern
Author
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Brendan Kennedy:
"You sir, have the boorish manner of a Yaley!"
(Sideshow Bob)
nah - I was in Chicago once, but I live in Dublin Ireland(and go to DCU).
hmm, looks like php has one up on jsp there in my book. Of course(just though of this now) I can run the php from my jsp using the runtime thing cos it can be run from the command line)...might have to setfacl the script though..
Thanks,
Brendan

Well, you can simply run programs directly in JSP as you do in PHP. I was just saying it's hard to do portably.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!