LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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


Reply
  Search this Thread
Old 04-19-2005, 03:12 AM   #1
borgy_t
LQ Newbie
 
Registered: Feb 2005
Location: philippines
Distribution: red hat 9
Posts: 26

Rep: Reputation: 15
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.
 
Old 04-19-2005, 03:32 AM   #2
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
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)).
 
Old 04-19-2005, 03:40 AM   #3
borgy_t
LQ Newbie
 
Registered: Feb 2005
Location: philippines
Distribution: red hat 9
Posts: 26

Original Poster
Rep: Reputation: 15
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?
 
Old 04-19-2005, 03:50 AM   #4
jonaskoelker
Senior Member
 
Registered: Jul 2004
Location: Denmark
Distribution: Ubuntu, Debian
Posts: 1,524

Rep: Reputation: 47
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing commands via ssh Comatose51 Linux - Security 1 04-13-2005 04:31 PM
passing passing variable in Java as reference djgerbavore Programming 3 11-10-2004 02:18 PM
shell scripting -- passing commands mehesque Linux - General 4 06-25-2004 10:28 AM
Passing multiple commands to SU adamrad Linux - General 2 03-26-2004 10:53 AM
shell problems ? cant run Java commands RedHat123 Linux - General 2 07-16-2002 10:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration