Having trouble in running a unix command and getting the output
Hi,
I am trying to run a unix command from within the java code. I am not able to make it work. I am enclosing the code and the error message that I am getting. Any help is highly appreciated.
import java.io.*;
public class RunCommand {
public static void main(String args[]) {
String s = null;
try {
Process p = Runtime.getRuntime().exec("cat UNIX_ASCII_TEXT_FILE | A_UNIX_PROGRAM -d");
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
// read the output from the command
System.out.println("Here is the standard output of the command:\n");
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
// read any errors from the attempted command
System.out.println("Here is the standard error of the command (if any):\n");
while ((s = stdError.readLine()) != null) {
System.out.println(s);
System.exit(0);
catch (IOException e) {
System.out.println("exception happened - here's what I know: ");
e.printStackTrace();
System.exit(-1);
}The error message that I am getting is
Here is the standard output of the command:
SLu|%%$$=
Here is the standard error of the command (if any):
cat: cannot open |
cat: cannot open A_UNIX_PROGRAM
cat: cannot open -dLooks like the cat command is working and not the pipe command and the command after the pipe. But when I run the UNIX command from the command prompt I get the expected result.
You might read this article and see if its approach works.
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
Similar Messages
-
How to run commands like "ipconfig" and get the output in adobe AIR in windows?
import flash.desktop.NativeProcess;
import flash.desktop.NativeProcessStartupInfo;
if (NativeProcess.isSupported) {
var npsi:NativeProcessStartupInfo = new NativeProcessStartupInfo();
var processpath:File = File.applicationDirectory.resolvePath("MyApplication.whatever");
var process:NativeProcess = new NativeProcess();
npsi.executable = processpath;
process.start(npsi);
The above can only run a sub-application, but how to run an independent application(command) like ipconfig and get the result?Hi,
here is an example of running a net Use command line from AIR, unig the new NativeProcess. Hope it will help !
function launchProcess()
var file = air.File.applicationDirectory;
// set command path
file = file.resolvePath("C:/Windows/system32/net.exe");
var nativeProcessStartupInfo = new air.NativeProcessStartupInfo();
nativeProcessStartupInfo.executable = file;
// prepare command parameters
var args = new runtime.Vector["<String>"]();
args.push('USE');
args.push('W:');
args.push('/delete');
args.push('/y');
// set arguments
nativeProcessStartupInfo.arguments = args;
// add listeners to catch command outputs
process.addEventListener(air.ProgressEvent.STANDARD_OUTPUT_DATA, onOutputData);
process.addEventListener(air.ProgressEvent.STANDARD_ERROR_DATA, onErrorData);
process.addEventListener(air.NativeProcessExitEvent.EXIT, onExit);
// create and run Native process
process = new air.NativeProcess();
process.start(nativeProcessStartupInfo);
function onOutputData(ProgressEvent)
var processResults = process.standardOutput.readUTFBytes(process.standardOutput.bytesAvailable);
air.trace("Results: \n" + processResults);
function onErrorData(ProgressEvent)
var processResults = process.standardError.readUTFBytes(process.standardError.bytesAvailable);
if(processResults.search('password') > -1){
window.alert('Bad password');
air.trace("Errors: \n" + processResults);
function onExit(NativeProcessExitEvent)
air.trace("Process ended with code: " + NativeProcessExitEvent.exitCode); -
Hi even since loading Lion, I am having trouble getting efficient connection to the internet via airport. whenever I logon I have to manually configure my MTUs to stay at 1392; then it take about 6 tries until it stays - it keeps defaulting back to 1500. When I log out it defaults to 1500
it was ok in the old snow leopard.
This is really annoying - it is the same on my iMac and Macbook
Can somebody assist? Me thinks a patch is requiredThis LION OS is Rubbish I hate it - I have sooooo much trouble now getting a decent internet connection because it does not hold the Flippin MTU; it reverts to 1500 - WHY
-
Hi all. Very, VERY new to FCP. I've used many of your suggestions on here to help me through a lot, so thank you!
This is just one issue that I can't seem to figure out.
I was working on a project yesterday without any problems.
Today when I went to work on it, Final Cut would start up, but it would display the beach ball forever once the start up routine was finished. The project would never load.
A note, I have all current App updates installed.
(I figured maybe this particular project didn't get updated for some reason, so I tried manually updating my projects and events, but when I went to select them in my 2nd drive, they were grey and I couldn't select them.)
Another note, other projects work perfectly fine when I go to open them. It's just when I go to open this particular one, Final Cut will not work. Endless beach ball.
I tried a suggestion that one user had, and that was to open two separate windows in Finder, and move the uncooperative library package contents into a new library. That didn't work either, and now I am unable to move the library package contents back to their original library. There is a yellow "!" triangle next to the library in Final Cut, so I'm wondering if this means that the file is corrupt.
Hopefully I've given enough information on here to shed some light on my problem. Any help would be greatly appreciated.If it was working on 10/1, why not open up the most recent backup library with a timestamp of that day. Unless you specified otherwise, your backup folder is in Movies in your home folder. You can double-click one to open it in FCP.
The update command actually wants a mounted drive selected.
I suggest not going into the library bundles and moving or modifying folders/files except as a last resort. It sounds like both libraries are corrupted.
Russ -
Run the Report as a Background job and Get the Output in Excel in Local PC
Hello Gurus,
I have one following requirement.
One should be able to run the report as a background job and it should be possible to get the report in Excel format, also when running the report in background. The excel report should have the same information and look as the current SAPreport.
Please provide some solution.
Any helpful answer get surely awarded.
Thanks a lot,
VarlanirGUI_* WS_* Function In Background, CSV Upload
GUI_* and WS_* function modules do not work in background
When scheduling a job in the background the appropriate statement to read in your file is OPEN DATASET, and the file must be on the file system that the SAP server can see.
At anytime, a user can switch of the Personal Computers even though the job is still running in the background. Therefore GUI_* and WS_* function modules are not designed to work in that way, as they need to access your personal computer file.
To choose the correct download method to used, you can check the value of SY-BATCH in your code,
if it is 'X' use OPEN DATASET and if it is ' ' use WS_UPLOAD.
*-- Open dataset for reading
DATA:
dsn(20) VALUE '/usr/test.dat',
rec(80).
OPEN DATASET dsn FOR INPUT IN TEXT MODE.
IF sy-subrc = 0.
DO.
READ DATASET dsn INTO rec.
IF sy-subrc <> 0.
EXIT.
ELSE.
WRITE / rec.
ENDIF.
ENDDO.
ENDIF.
CLOSE DATASET dsn.
*-- Open dataset for writing
DATA rec(80).
OPEN DATASET dsn FOR OUTPUT IN TEXT MODE.
TRANSFER rec TO '/usr/test.dat'.
CLOSE DATASET dsn.
What is the difference when we use upload, ws_upload, gui_upload function modules?
UPLOAD, WS_UPLOAD, GUI_UPLOAD, are used in BDC concepts. ie., Batch Data Communication.
Batch Data Conversion is a concept where user can transfer the Data from non SAP to SAP R/3. So , in these various Function Modules are used.
UPLOAD--- upload a file to the presentation server (PC)
WS_UPLOAD---- Load Files from the Presentation Server to Internal ABAP Tables.
WS means Work Station.
This is used upto SAP 4.6 version.
GUI_UPLOAD------- Replaces WS_UPLOAD. Upoad file from presentation server to the app server. From 4.7 SAP version it is replaced.
How to Upload csv file to SAP?
Common File Download Upload Questions:
How you upload the data from text file to sap internal table? From my knowledge its by upload or gui_upload.
How you download the data from sap internal table to text file?
How you upload the data from xls (excel) file to sap internal table how you download the data from sap internal table to xls(excel) file.
You can upload data from presentation server to an internal table using gui_upload. Use gui_download to download from internal table to flat file.
Use fm ALSM_EXCEL_TO_INTERNAL_TABLE to upload data frm excel.
Use function module GUI_UPLOAD
The FILETYPE refer to the type of file format you need: For e.g 'WK1' - Excel format , 'ASC' - Text Format etc.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\test.csv'
FILETYPE = 'ASC'
TABLES
DATA_TAB = itab
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17. -
Execute linux command and getting its output in java
i want to run a simple command from java: telnet localhost 8649 > report.txt
how can I do this.See java.lang.ProcessBuilder
-
Run VL06 in Background and getting the report in AL11
Hello ,
My requirement is as follows.
I need to develop a program which should VL06 tcode for Listing the Outbound deliveries in BACKGROUND with a specific variant and Layout and then the report data should be dumped to the given AL11 file path .No need to display the report.
I tried with Submit statement but here I can use the variant but not Layout option as Layout field is not the part of selection screen of VL06 tcode for lsitingthe outbound deliveries.
Can anybody please advice about how to proceed with this.
Thanks in Advance.....Hello ,
Thanks for the reply ....
I tried with that ..i could see the list ...but i wanted to capture the same with predefined layout inthe result ofthe report .
There is no layout selction option in the selectionscreen of the report.
Please advice. -
How to execute this Procedure and get the output?
I have created a Procedure the source code of the same is furnished below.
create or replace procedure vin_test( p_deptno IN number
, p_cursor OUT SYS_REFCURSOR)
as
v_res Emp%rowtype;
begin
open p_cursor FOR
select *
from emp
where deptno = p_deptno;
end vin_test;
Now, if i want to see the out put of this Proc
i will first set the Serveroutput on and then..
Exec vin_test(10);
I am getting an error saying wrong number of arguments,so can anybody tell me what parameter value should i pass on so that i can get desired output.
Thanks in Advance
OraCrazyIn sqlplus you can do like this.
SQL> create or replace procedure vin_test( p_deptno IN number, p_cursor OUT SYS_REFCURSOR)
2 as
3 v_res Emp%rowtype;
4 begin
5 open p_cursor for
6 select *
7 from emp
8 where deptno = p_deptno;
9 end;
10 /
Procedure created.
SQL> var lcur refcursor
SQL> exec vin_test(30,:lcur)
PL/SQL procedure successfully completed.
SQL> print lcur
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO DIV
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 10
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 10
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 10
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 10
7900 JAMES CLERK 7698 03-DEC-81 950 30 10
6 rows selected.Thanks,
Karthick. -
I'm having lots of difficulty captioning my photos in organiser and have repaired and optimized my catalogue - any ideas please?
Try adding captions via the properties panel. Right click on your first thumbnail and choose Show Properties from the bottom of the context menu.
You can enlarge the panel by dragging the bottom right corner. Make sure you are using the general tab. Enter your text in the caption field, then use the right arrow key to move to the next thumbnail.
It’s an alternative way of adding captions which uses less memory than opening images full screen.
Click to view -
HT203167 Is anyone having trouble with downloads that you don't get the full song?
I have bought two cd's to burn for my brother. They both have a song that did not download the whole song. I was able to re-download the one song for one of them, but the other one, I have to re-purchase the whole CD, which was $20.00 Is there a way that I can get that one song without having to but the whole cd again?
Assuming you are in a region where you are allowed to redownload your past music purchases, delete the corrupt tracks from the music section of your iTunes library, close & then reopen iTunes, go to the iTunes Store home page, click the Purchased link from the Quick Links section in the right-hand column, then select Music and Not on this computer. You should find download links for your tracks there.
While downloading select Downloads in the left-hand column and make sure Allow Simultaneous Downloads is unchecked. This seems to help with partial downloads...
If the problem persists, or that facility is not yet available in your region, contact the iTunes Store support staff through the "Report a problem" links in your account history, or via Contact Support.
See also:
HT5085 - iTunes in the Cloud and iTunes Match Availability
HT2519 - Downloading past purchases from the App Store, iBookstore, and iTunes Store
tt2 -
Getting the output of system commands in air
Hello-
Can someone explain how with flex and air one would run a
system command and save the output to an array or string?
Thanks.Running other programs, including system commands, is not
supported by AIR at this time. -
How to run a unix command in java
Hi all,
I need to run a unix command in my standalone java application.my java program is in windows.Is it possible to run unix command on windows system.help me out.
I tried this
Process p = Runtime.getRuntime().exec("ps -ef");
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));i get IO Exception -Create Process ps-ef error=2If you want to run a command from java for a windows platform, you should check windows knows the command.
So, load up a DOS prompt and type ps -ef and see what happens. -
How to run piped Unix commands
Hi,
I'm trying to run piped Unix commands using Runtime.getRuntime().exec(...) but apparently the pipe symbol ("|") doesn't seem to work...
Here is basically what I'm trying to do: running "command1 | command2" where both "command1" and "command2" have dynamic values. I could create a shell script and execute it through Java but there has to be a cleaner way...
Can anyone help me with this?
Thanks,
ThierryThe | symbol for a pipe is understood by a shell, so it was right to point to this direction.
If you still have a problem, that might be because of another reason. What did happen, how exactly� did it not work? Did you take care of the stdin and stdout channels of the launched process? -
Having trouble with running an APP transferred from my imac?
Having trouble with running an APP transferred from my imac?
It asks me to sign in. I sign in and nothing happens.
-
how do I run a unix command to quit ARD if it is running on a remote server I am trying to access?
killall "Remote Desktop"
Regards.
Maybe you are looking for
-
Status metric for the OEM plugin for DB2 Databases
Hi, I am doing some testing of the OEM system monitoring plug-in for an IBM DB2 Database. I am starting with some very basic alerts such as when an instance is down. However, it is not working as I would expect. When the instance is stopped using the
-
Help on Sitecatalyst Integration
All, Need help with Sitecatalyst Integartion. Using AEM 5.6. Referred to the below link, https://dev.day.com/docs/en/cq/5-6/administering/integrating_with_adobe_marketing_cloud/si tecatalyst.html Could someone please guide me with steps . I set up a
-
The solution provided in the other discussions are not working for me. The 'vsearch' solution given in other discussions doesnt work. I dont know what I have downloaded but now whenever I type anything in safari or click or double click then a new ta
-
Solr Collection PDF display problem
I am having problems getting the Search collection I created to display the PDF files. When I perform a search I am able to get the pdf file listing put when I select a PDF file to display it it does nothing. Please help, below is the Search Action
-
Itunes library . xml disappears how recreate it. If possible in french
Bonjour j'ai effacé par erreur iTunes Library .xml, donc plus de possibilité d'utiliser la bibliothèque Itunes dans Imovie, Garageband etc .... Que dois je faire ? Comment recréer seulement iTunes Library .xml ? Dois je supprimer et réinstaller iTune