Interpreting java output stream as system commands in Solaris


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Interpreting java output stream as system commands in Solaris
# 1  
Old 07-18-2007
Interpreting java output stream as system commands in Solaris

Hi there again,

Running Solaris 10 with built-in Java. Seems to compile and run fine.

Problem is: Say I want to see contents of current directory. In a shell, I'd just write "ls" and it outputs the content.

When I write a Java file, I have the following line:

System.out.println("ls");

But when I run the file, what it does is echo "ls" itself to the screen, instead of sending it to the shell as a command (so instead of seeing directory contents all I see is the text "ls"). What should I change the above line to, so that "ls" is sent to the shell as a command, instead of just echoed?
# 2  
Old 07-18-2007
That is because System.out.println is the equivalent of printf or echo.

Try java.lang.Runtime.exec()
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Interpreting Linux's free command output

I have two questions on Linux's free command. Below, I have provided output from my home laptop (fedora 26 ) which has 16GB Physical RAM and a production server (RHEL 7.4) which has 24GB RAM. Question1. What exactly does the buffer/cache column say in free command's output ? buffer/cache is... (9 Replies)
Discussion started by: omega3
9 Replies

2. Shell Programming and Scripting

Setting a variable in a stream of commands

can someone help me with this? AgentDX=/tmp/tesfinal && cat final.enc | openssl aes-128-cbc -a -d -salt -k hello | sh the content of final.enc is a code. and in that code, the value of AgentDX is needed. however, i cant seem to find a way to allow the code to recognize that the variable... (4 Replies)
Discussion started by: SkySmart
4 Replies

3. Shell Programming and Scripting

how to fetch the commands at solaris system

:wall:i'm system administrator. now i have a trouble. i want to fetch the command which the login users performed by shell.but i don't know how to process this problem.if anyone tell me how to do this work I would be very grateful.thank you! (4 Replies)
Discussion started by: anline5104
4 Replies

4. Solaris

How can I output all previous Unix commands in Solaris to a file??

Hello friends: I login to solaris with a username/Password and I can see quite a lot of previous I use dbefore, it accumulates a lot, I hope to output them into a Command.txt file as reference, not copy/paste 1 by 1, is there any way I can collect all commands in batch then put into a file, ... (3 Replies)
Discussion started by: sunnysunnysunny
3 Replies

5. Solaris

Interpreting xntpdc output.

Hi. I wonder what the equal sign in front of the answer means. I have read man pages and googled but found no answer. xntpdc -p =15.5.64.3 15.5.2.51 3 512 377 0.02060 0.057426 0.04965Thanks. Jan (1 Reply)
Discussion started by: vettec3
1 Replies

6. UNIX for Dummies Questions & Answers

Interpreting prtdiag output - 2 or 4 CPUs?

I am having trouble figuring this one out.....Is this a 2CPU or a 4CPU v490 with 16GB? I think it is a 2CPU system, looking for confirmation. $ prtdiag System Configuration: Sun Microsystems sun4u Sun Fire V490 System clock frequency: 150 MHz Memory size: 16384 Megabytes ... (1 Reply)
Discussion started by: config_boy
1 Replies

7. UNIX for Dummies Questions & Answers

interpreting netstat output

hi all, when I run- wcars1j5#netstat -an | grep 8090 127.0.0.1.8090 *.* 0 0 49152 0 LISTEN wcars1j5# 1. does this mean that no one is connected to this port? Regards, akash (1 Reply)
Discussion started by: akash_mahakode
1 Replies

8. Solaris

rsh commands not getting executed from Solaris 10 System to AIX System

Hi Friends, I am trying to execute rsh commands from Solaris 10 system to AIX system. When I give; Solaris10# rsh <hostname> ls -l , it gives me an error rshd : 0826-826 The host name for your address is not known At the same time, Solaris10# rsh <hostname> ---- gives me remote shell of... (25 Replies)
Discussion started by: jumadhiya
25 Replies
Login or Register to Ask a Question