Author Topic: [Help me!] > Execute Unix shell command as root with Java?  (Read 3946 times)  Share 

0 Members and 1 Guest are viewing this topic.

Offline thanachit

  • นักศึกษาปริญญาตรี
  • เทพไอที
  • *
  • Posts: 877
  • Karma: +0/-0
  • Gender: Male
  • somebody out there
[Help me!] > Execute Unix shell command as root with Java?
« on: August 29, 2008, 08:21:21 AM »
ปัญหาของผม คือ ผมต้องการจะสร้าง java application
คล้าย ssh client คือ มีส่วนของการ authenticate
รับ hostname/ip username passwd port จาก user
แล้ว connect ไปยัง remote unix server

เพื่อ ทำการ manage unix server ผ่าน java application
ยกตัวอย่างเช่น shutdown เครื่อง ด้วย shutdown -h now
manage directory/file (cp , mv , rm )

สิ่งที่ผมต้องการจะถามคือ
1. java application ที่ไม่ได้อยู่บนเครื่อง server จะ connect
ไป unix server เพื่อ execute shell command , shell script ได้ไหม
2. java application จะสามารถเป็น ssh client ได้อย่างไร
ต้องเขียน Program ประเภท socket ไหม? หรือว่ามี Library
ให้เรียกใช้อยู่แล้ว
3. มีวิธีอื่นที่จะ manage unix server แบบที่ต้องทำการ authenticate
ที่ shell ก่อน เช่น บางคำสั่งจะ execute ได้ ต้องใช้ account root
4. runtime.exec(); ใช้ได้เฉพาะในกรณีที่ java application นั่นอยู่บน server หรือเปล่า
และเวลามัน execute shell มันจะ execute ด้วย permission ของใครครับ
ของเจ้าของ java application นั้นหรือเปล่า

ถ้าผมถามแบบงง ๆ ก็ขอโทษด้วยนะครับ
I wanna be there when you're in need.

Offline ▒▒▒ Kivi .ılı..ılı. 陳 鋼 石 ▒▒▒

  • นักศึกษาปริญญาโท
  • ไอทีเฟรชชี่
  • **
  • Posts: 90
  • Karma: +0/-0
  • Gender: Male
  • หน้าใสใจหื่น
    • hi5
Re: [Help me!] > Execute Unix shell command as root with Java?
« Reply #1 on: August 29, 2008, 08:56:40 AM »
ไม่รู้ว่าจะตรงกับคำถามที่ต้องการป่าวนะ

http://www.jscape.com/articles/ssh_using_java.html

http://www.javassh.org/space/Installing+as+a+local+Telnet/SSH+Application
« Last Edit: August 29, 2008, 08:59:17 AM by ▒▒▒ Kivi .ılı..ılı. 陳 鋼 石 ▒▒▒ »
 

Offline thanachit

  • นักศึกษาปริญญาตรี
  • เทพไอที
  • *
  • Posts: 877
  • Karma: +0/-0
  • Gender: Male
  • somebody out there
Re: [Help me!] > Execute Unix shell command as root with Java?
« Reply #2 on: August 29, 2008, 11:59:19 AM »
ขอบคุณมากครับ
เป็นประโยชน์จริงๆๆ
I wanna be there when you're in need.

Offline WingGundamZeroCustom.co.th

  • นักศึกษาปริญญาตรี รุ่นที่ 2
  • พระเจ้าจอร์ช มันขุดได้ยอดมากเลย
  • *
  • Posts: 2,726
  • Karma: +1/-0
  • Gender: Male
  • My name is Rx-93 ν Gundam
    • Blog@WingInfotech.net
Re: [Help me!] > Execute Unix shell command as root with Java?
« Reply #3 on: August 29, 2008, 01:12:47 PM »
ถ้าให้คิดหลักการก็คงประมาณใช้ library connect เข้าไปยัง ssh แล้วก็ execute คำสั่งตามที่ต้องการ เหมือนเป็น GUI ครอบตัว command line อีกทีนึงหรือเปล่า
I will change the world, to the better day.

My blog, My world: http://blog.winginfotech.net




Offline thanachit

  • นักศึกษาปริญญาตรี
  • เทพไอที
  • *
  • Posts: 877
  • Karma: +0/-0
  • Gender: Male
  • somebody out there
Re: [Help me!] > Execute Unix shell command as root with Java?
« Reply #4 on: August 30, 2008, 01:10:03 AM »
ถูกครับ
I wanna be there when you're in need.

Offline ^DoppLer 2 SulPhaTe^

  • นักศึกษาปริญญาตรี
  • พระเจ้าจอร์ช มันขุดได้ยอดมากเลย
  • *
  • Posts: 2,307
  • Karma: +0/-0
  • Gender: Male
  • รักเพื่อน เคารพพี่ ดูแลน้อง ตอบแทนผู้มีพระคุณ
Re: [Help me!] > Execute Unix shell command as root with Java?
« Reply #5 on: August 30, 2008, 11:06:04 AM »
ทำไมผมอ่านแล้วรู้สึกโง่ขึ้นมาทันตา

Offline thanachit

  • นักศึกษาปริญญาตรี
  • เทพไอที
  • *
  • Posts: 877
  • Karma: +0/-0
  • Gender: Male
  • somebody out there
Re: [Help me!] > Execute Unix shell command as root with Java?
« Reply #6 on: August 30, 2008, 11:15:29 AM »
คิดมาก
I wanna be there when you're in need.