Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
04-19-2005, 03:12 AM
|
#1
|
LQ Newbie
Registered: Feb 2005
Location: philippines
Distribution: red hat 9
Posts: 26
Rep:
|
Java: passing linux shell commands
i have a question... programtically, how do i pass linux commands from a java program that is running on windows to a linux box running samba? all i have to do is to clear files in my folder there.
|
|
|
04-19-2005, 03:32 AM
|
#2
|
Senior Member
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524
Rep:
|
well, afaik Samba, it's just a file/print server; that is, you get to transfer files and print jobs (but not much more).
If you insist on using samba, you could transfer a shell script and program the recieving end to run it. However, this poses a security question: how do you make sure that only you can run code (through your programs) and no one else can?
alternatively, log in remotely via ssh and run commands through that--I think java will happily give you a triplet of streams (std(in|out|err)).
|
|
|
04-19-2005, 03:40 AM
|
#3
|
LQ Newbie
Registered: Feb 2005
Location: philippines
Distribution: red hat 9
Posts: 26
Original Poster
Rep:
|
my apologies, i haven't elaborated very well on my problem.
what i need to do is clean the /home folder of all users of the linux box who are offline, using my java program which is running on windows.
i was thinkin of using Runtime.exec to pass the commands but is this possible?
|
|
|
04-19-2005, 03:50 AM
|
#4
|
Senior Member
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524
Rep:
|
No; Runtime.exec will only run commands locally. What you can do is run an ssh client (google PuTTY) locally, which will then log in to your GNU/linux box and run commands from there--which of course requires you to have sshd running on it.
Anyhew, that's how I'd do it.
As for cleaning the /home/.../, I assume you know what you want to do and how to do it (if not, feel free to ask).
--Jonas
|
|
|
All times are GMT -5. The time now is 07:57 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|