reddy ajay

Greenhorn
+ Follow
since Apr 21, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by reddy ajay

Vishal Hegde wrote:Hi Bear,

I have a Jsp page having add hyperlink.Once clicked it redirects to a JSP page where i input name email address and all and once clicked on submit button the form action attribute is set to go to prepared_statement_query servlet to add the values in the database...

I was hoping that select statement in SQL query will display new values i inputted in the jsp page.but no luck the table remains the same and is not added with any new information



did you create the database in mysql and the table,
if you did not the you need to do that first.
Also debug it using debugger and see what is happening
is it running fine or is it raising some exception.
let me know

Rob Spoor wrote:It also won't work since the | is a shell tool, and won't be treated as such by Runtime.exec that only can handle single processes, not combined processes like these.

You may be able to use process.getInputStream() and write to that, but I'm not sure.



use :
String[] cmd = {"/bash/bin","-c","echo password| sudo -S installer -pkg /yourdirectory -target"};
Runtime.getRuntime.exec(cmd);

Works smooth.....I totally nailed it.
PEACE!!!
12 years ago

geek mr wrote:

James Sabre wrote:

Rob Spoor wrote:It also won't work since the | is a shell tool, and won't be treated as such by Runtime.exec that only can handle single processes, not combined processes like these.

You may be able to use process.getInputStream() and write to that, but I'm not sure.



And even if you get the shell involved by using


it doesn't work in Ubuntu 11.04 or 10.10 since one is still prompted for the password. The problem is that the password has to entered through the 'keyboard' device and not through 'stdin'.

I would be interested to know details of the system "geek mr" used to test this.



I ran this on my mac OS in the command line interface and it ran just fine......I dont know why you guys have trouble running it. I guess, You have to get the shell involved using bash -c when trying to run from java code......just give this command "echo password |sudo -S installer -pkg /YOURDIRECTORY -target / on your command line interface in mac OS....and its gonna run fine.
I understand its not secure but there is no other way to get your work done. So this might well be it.



I have worked with the whole thing now and it worked perfectly fine when i ran it from my java code....all i had to do was to invoke shell by using
String[] cmd= {"/bin/bash", "-c", "echo password |sudo -S installer -pkg /YOURDIRECTORY -target /"};
Runtime.getRuntime.exec(cmd);

PEACE OUT!!!
12 years ago

James Sabre wrote:

Rob Spoor wrote:It also won't work since the | is a shell tool, and won't be treated as such by Runtime.exec that only can handle single processes, not combined processes like these.

You may be able to use process.getInputStream() and write to that, but I'm not sure.



And even if you get the shell involved by using


it doesn't work in Ubuntu 11.04 or 10.10 since one is still prompted for the password. The problem is that the password has to entered through the 'keyboard' device and not through 'stdin'.

I would be interested to know details of the system "geek mr" used to test this.



I ran this on my mac OS in the command line interface and it ran just fine......I dont know why you guys have trouble running it. I guess, You have to get the shell involved using bash -c when trying to run from java code......just give this command "echo password |sudo -S installer -pkg /YOURDIRECTORY -target / on your command line interface in mac OS....and its gonna run fine.
I understand its not secure but there is no other way to get your work done. So this might well be it.
12 years ago
You can acutually call by accessing the command prompt and from there we can call the installer.
We can access the command prompt by,
Runtime.getRuntime.exec(echo password| sudo -S filepath -target)

Hoorah!!!
12 years ago
Hi, I struggled with the same issue for hours and finally got the solution.
HERE it is. Brace yourself:
echo "password"|sudo -S installer -pkg /YOURDIRECTORY -target /

"password" would be your password....you can give this in one line in java as: Runtime.getRuntime().exec(s);
hope this helped and let me know if it doesnt work because it worked for me and i can help you out
12 years ago
can you guys show me how i can call a setup file from my java code and then perform the normal installation in the installation directory which i choose from the GUI. i should then be able to normally start the program from the windows start tab.
12 years ago