Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Trying to read a file on Unix into a file on windows or into a string builder

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I am trying to read a file on a remote server, which is on a Unix box. I don't mind if I can read it into a Stringbuilder or a file. The normal

which works well on windows would work for me.

So I am using SSH to connect, and then I am running commands
eg Cat /var/log/logfile.

I can view the content of the file on the console, but I cannot save it to a string or write to the file. I am having a nightmare with Converting the OutputStream to String or even FileOutputStream


here is a snippet



So my question is this, after running the command, I can see the command and the returned stuff in the console, but I am not having any luck writing the content into the file. I am able to write the first line into the file - out.write((command+";echo \'z4a2ce4f3317Z\'").getBytes()); this writes the command into the file, but the next lines which contains stuff returned is not copied to the file




 
Marshal
Posts: 26750
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps I am misunderstanding all of that, but if you want to write your data to a String instead of a File, then why not just write to a StringWriter instead of a FileOutputStream?
 
Sege Stephen
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will have a look at stringWriter. Thanks
 
Sege Stephen
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am still unable to solve this, all I want to do is to write the bytes in the outPutstream as a String. ie

run a Linux command, eg ls -l, and get the result / output stored in a String. Please help
 
Sheriff
Posts: 3036
12
Mac IntelliJ IDE Python VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That doesn't seem to be the same question, but here's one way you could run "ls -l" and capture the output in a string:

 
Whoever got anywhere by being normal? Just ask this exceptional tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic