• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Open "vi" Editor from java

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
Plz I need your help;;;
I am writing a java programe that has to open the "vi" editor, on linux Operating System..

I tried this code
Runtime.getRuntime().exec("vi test.txt");

but it didn't work,,

Any idea plz???
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What was the output? It should have opened it somewhere, maybe you're not seeing it.
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The way it is executed, it may not have opened anywhere. To do that, you need to execute a shelltool or xterm first -- which then can run the "vi" command.

Henry
 
Raed Qudaisat
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Henry Wong:
The way it is executed, it may not have opened anywhere. To do that, you need to execute a shelltool or xterm first -- which then can run the "vi" command.

Henry



thanx for answering,,
what do you mean by you need to execute a shelltool or xterm first???

any example code plz???

I'm writing a console application that draw a screen and show all of it's contents files "available files" the user will choose the wanted file with arrows,, and when his/her wanted file is highlighted he can press return "enter" to open his/her file with the "vi" editor.....

i wrote this for proop of concepts

************
Runtime rt = Runtime.getRuntime();
Process ps = rt.exec("vi test.txt");
OutputStream os = ps.getOutputStream();
InputStream is = ps.getInputStream();
DataOutputStream dos = new DataOutputStream(os);
dos.writeBytes("i");
dos.writeBytes("test");
dos.writeBytes("\u001B");
dos.writeBytes(":wq\n");
dos.flush();
ps.waitFor();
dos.close();
System.out.println(ps.exitValue());
****************
and a "test.txt" file has been created with a inner-text "test".....

i don't want to get the output stream for the Process to wrtie on the file,,, i hope if i can display it for theuser to do his/her modifications


thanx again
[ December 29, 2005: Message edited by: Raed Qudaisat ]
 
Normally trees don't drive trucks. Does this tiny ad have a license?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic