How to execute more than one command in a Process
Hello all,
I would like to change the user in my application by
using the unix command su user and then execute some commands as this user.My code is the following, my problem is to execute other commands after execute the su command.
public static void main(String [] args)
try
Runtime r = Runtime.getRuntime();
String msg = "";
String emsg = "";
int len = 0;
byte buffer [] = new byte[100];
Process p1 = r.exec(new String [] "su","user"});
InputStream input = p1.getErrorStream();
len = input.read(buffer);
System.out.println(new String(buffer,0,len));
OutputStream out = p1.getOutputStream(); String password = "password";
out.write(password.getBytes());
out.flush();
out.close();
System.out.println(password);
p1.destroy();
catch(Exception e)
System.out.println(e.toString());
For those of you who are "shell challenged", here's a Java program that will tell you how the shell interprets the command and argument you give it:
public class RuntimeHelper {
public static void main(String[] args) {
for (int i = 0; i < args.length; i++)
System.out.println(args);
When you run the program with
java RuntimeHelper su username -c "cmd arg1 arg2"
the output is:
su
username
-c
cmd arg1 arg2
Each line shows one argument that the shell passed to the java command.
Similar Messages
-
How to send more than one command at the same time to write buffer in VISA READ?
Hi,
I'm using the LABVIEW->serial.VI with a small modification for my serial communication with a shutter control unit.At present,I can send one command CTSO1 to the write buffer.My instrument can read upto 5 commands.I want to send CTSO1 and CTSO2 simulatenouly so that i could open two shutters simulatenously.Note that commands have carraige return constants as terminatting characters.I'm enclsoing the VI which works for one command.
Any help in this regard is greatly appreciated!
Regards,
Rajesh
Attachments:
VI_SHUTTER_JUNE30.vi 50 KBYou cannot do two different simultaneous VISA writes over a serial bus. There is a single rx line on the pc's com port and a single rx line on the instrument. You only hope is if the instrument allows you to chain commands and the reception of the carriage return triggers the instrument to implement both at the same time. Maybe you can send CTS01 and CTS02 separated by a space or comma. The manual should tell you if that's possible or maybe you need to ask the manufacturer.
-
Executing more than one procedures at a time
Hi,
Can any one tell how to execute more than one procedure at a time..
I am trying to run like this..but its throwing an error...can anyone please suggest?
CREATE OR REPLACE PROCEDURE HYSXM.QA_AUTO_RETURN_FINAL IS
i EVENTS_TEST_DATA%ROWTYPE;
BEGIN
DELETE FROM TEST_EVENTS;
COMMIT;
for i in ( SELECT RADIO_ID,EVENT_TYPE FROM EVENTS_TEST_DATA )
LOOP
QA_AUTO_INSTALL(i.radio_id,i.event_type);
QA_AUTO_RESOLD(i.radio_id,i.event_type);
QA_AUTO_RETURN(i.radio_id,i.event_type);
END LOOP;
END QA_AUTO_RETURN_FINAL;
/what error message is being returned??
-
Execute more than one times external command of OS Windows NT
Hi all,
I have to execute more than one times from an ABAP program an exernal command of Operating system windows NT . In order to reach this goal I found the standard program RSBDCOS0 and it works very well if you execute it one time. Unfortunately I have to execute this external command more than one times. Is there any soluiton?
thank to all
Gino BonfiglioliWell why are you using this report RSBDCOS0 to execute external commands?
Because SAP provides certain function modules that can be used to call operating system commands; so you can use these functions to do your task.
Just check the following link
http://help.sap.com/saphelp_nw2004s/helpdata/en/fa/0971e1543b11d1898e0000e8322d00/frameset.htm
As you mentioned that you need to execute multiple times, you can easily put the call to function module inside a loop or do/enddo structure. for example consider the following
do 3 times.
call function 'SXPG_COMMAND_EXECUTE'
exporting
commandname = 'Put operating system command here'
additional_parameters = full_filename
targetsystem = targtsys
stdout = 'X'
stderr = 'X'
terminationwait = 'X'
importing
status = sxpg_status
exitcode = sxpg_exitcode
tables
exec_protocol = sxpg_results
exceptions
no_permission = 1
command_not_found = 2
parameters_too_long = 3
security_risk = 4
wrong_check_call_interface = 5
program_start_error = 6
program_termination_error = 7
x_error = 8
parameter_expected = 9
too_many_parameters = 10
illegal_command = 11
wrong_asynchronous_parameters = 12
cant_enq_tbtco_entry = 13
jobcount_generation_error = 14
others = 15.
write the results
loop at sxpg_results.
write:/ sxpg_results-length,
sxpg_results-message.
endloop.
refresh sxpg_results.
enddo. -
How to prevent executing more than one client from a machine?
Hi all,
Currently I am doing a client server project in java. The client is java swing. There is a requirement to prevent executing more than one client from a machine.
Now I am relying on socket for this. I listen to a port, say 15000 and when the second session is started it would give an exception at the socket. I know that this a trivial method. Can anybody please suggest a better method. Also is it possible to bring focus to already executing client, if the user tries to execute the client program again in the same machine?
An early answer to this question is highly appreaciated.
Thanks in advance
SSMThanks for the suggestion, but I dont think we can use socket for this. And again if we use file for the same as you described, I think it would sometime create a some serious side effects. Suppose after one client session is invoked, the power goes off. In this case the client shut down is not in the normal sequence and hence we cannot remove the file programaticaly. This creates big problem when the user tries to run client again.
I am really interested to know, is there any standard way in java which can be used to achieve this. Also is it possible to give focus to already executing client program if the user tries to invoke the client again.
Thanks
SSM -
Execute more than one thing at the same time.
Hey why every time i want to execute more than one thing(create tables) at the same time
it say "ORA-00911: invalid character" , i dont wanna execute one thing at a time. check the pic please
http://img370.imageshack.us/img370/5120/oraclesw5.jpg
but in my school i use something called isqlplus and i can execute all the things i want at the same time with-out any error.
im using right-know
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production1) Unless you are using something like DBMS_JOB, SQL*Plus, iSQL*Plus, the Oracle XE web-based front-end, or any other application is going to execute one SQL statement at a time.
2) There is a dedicated XE forum-- the folks over there might know how to run a script using this particular front-end.
3) Assuming the XE database is on your local system, you should be able to log in via SQL*Plus and use that utility to run your scripts.
Justin -
How to share more than one Time Machine folder
Hi,
With Snow Leo Server I found how to find how to share more than one Time Machine Folder but I can't see how to do the same with Lion Server, could you help me with that ?
The goal of that is to offer one TM folder per user which is located on a dedicated partition in order to limit the size of TM backups per user (150Gig).
In Lion, in can only share one TM folder for everybody and I didn'tfind if I can set a limit size per user...
Thank you in advance,I have figured out a way to enable multiple backup targets.
However, it's one of these things I wouldn't want to describe to anyone except true programmer types, because everyone else has a 90%+ chance of messing up their system if they do something wrong.
It involves turning off file sharing, and then editing the plist files in /private/var/db/dslocal/nodes/Default/sharepoints/
The gist of it is this:
a) first create all the share points you later want to use for TimeMachine, and set them up for afp-only file sharing, also create one TM target, which you can either use later, or have there so the system has one entry it knows how to handle. I just made a bogus one that I'm not actively using.
b) turn off file sharing in Server.app
c) turn off TimeMachine in Server.app
d) now you can edit the files, the easiest is with Xcode, so you may want to install that first
e) for each sharpoint you made in a) there will be a corresponding .plist file in the location indicated, these are the files that need to be edited.
f) for each of these files
1) the item0 string property in the timeMachineBackup array must be switched from 0 to 1
2) a new key of type array with the name timeMachineBackupUUID must be created
3) in the newly created array an item of type string must be placed with the value of a UUID, which can be created with the shell command uuidgen
g) make sure all the edited plist files are saved
h) turn on TimeMachine in the Server.app again
If all went well, you now should be able to go to one of your networked client computers and see all the time machine share points just created as options for being a time machine target.
Anyway, if you go that route: be careful, don't blame me if you muck things up... -
How to start more than one program automatica​lly? [RT]
Normally you can build an application and let it start automatically on the PXI system. You have to put the file into c:\ni-rt\startup\
But how to start more than one application in a pre-defined sequence? Depending on the situation there are several programs to be started that run simultaneously.
I searched for help in the Development Library and the Forums but I didn't find an answer.
Thank you very much for your helpin advance! Have a nice day!
ChristophHi Christoph,
You can use VI Server on the real-time target to launch other VIs dynamically. Your startup executable could be a simple application that uses VI Server to start other VIs that run in parallel in a pre-defined sequence.
Here's an example that does something similiar.
Note that when you build the VI into an application, you must include all the VIs that are called by VI Server as dynamic VIs in the application builder.
-Gerardo -
How to add more than one datafile while creating tablespace
how to add more than one datafile while creating tablespace. I know by using alter command i can add datafile but i want while creating tablespace
Hi Dadivela,
how to add more than one datafile while creating tablespace.Here is the syntax:
!http://www.dba-oracle.com/images/create_tablespace.jpg!
I do it like this:
create tablespace myts
datafile
*'/u01/app/oracle/db1.dbf' size 100m,*
*'/u02/app/oracle/db2.dbf' size 200m;*
Here are my complete notes:
http://www.dba-oracle.com/t_tablespace_create_alter.htm
Hope this answers your question . . .
Donald K. Burleosn
Oracle Press author -
How to show more than one record at a form-like style report?
Hi All,
I developed a form-like style report
I want it to show more than one record at once (At the same page)
I tried that by setting the value to "Maximum records per page" property for the repeating frame to 10
but when I close the property palete and open it agian the value is returned to 1 !!!
how to show more than one record at the same page?????
Thank uHi,
there's perhaps another property like "page protect". If than 2 records didn't fit at one page there's a page break. Or is there any object inside the repeating frame with page-break properties? Sorry .. it's like looking into a chrystal ball ...
Regards
Rainer -
Dear All
Can anyone give me simple instructions on how to use more than one ipod on the same computer with itunes. My daughters have a different generation 'nano' each & my wife a 'shuffle'?
Many thanksClick here for options.
(69081) -
How to select more than one slide on Keynote?
Please, someone knows how to select more than one slide on keynote for IPad?
// Allow selection to span one contiguous set of rows, visible columns, or block of cells
table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
// Allow multiple selections of rows, visible columns, or cell blocks
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); -
How to display more than one documents on windows 8 desktop?
how to display more than one documents on windows 8 desktop?
Adobe Reader Touch doesn't show more than one file on screen and doesn't show them on the desktop. Apparently these are very old fashioned things that Microsoft doesn't think we'll want to do any more and calls them "legacy" to make them sound antiquated.
If you want to do these things use the legacy Adobe Reader, a much more powerful and flexible app (and not obsolete in the slightest). http://get.adobe.com/reader . There are no legacy apps in the Windows App Store. -
How to make more than one partition on Airport Time Capsule?
how to make more than one partition on Airport Time Capsule?
Only for the very brave......
Open up the Time Capsule (voids the warranty)
Pull the hard drive
Place the hard drive in a separate enclosure
Connect the enclosure directly to your Mac
Use Disk Utility to partition the hard drive
Reinstall the hard drive back in the Time Capsule
For the rest of us.....
The next best thing might be to set up one or more disk images on the Time Capsule, which will allow you reserve a given amount of space for each disk image.
Open up Macintosh HD > Applications > Utilities > Disk Utility
Click on the New Image tab
Navigate to the Time Capsule
Set up the disk image by naming it and specifying how much space you want to reserve -
How to attach more than one picture on an email
How to attach more than one picture on an email?
Tap the square with arrow on top right and select pictures you want to send (max 5 pictures)
http://i1224.photobucket.com/albums/ee374/Diavonex/f0bd7d73.jpg
Maybe you are looking for
-
WSIL-Servlet cannot read existing WSDL-Files
I've posted this question before in the adapters-forum, but the longer i think over it, i am sure that it belongs to this forum. So i'd like to apologize for cross-posting this one. I've installed SoaSuite 10.1.3.3 and OracleAdapters 10.1.3.1 with th
-
Bulletin Board recommendation needed
Greetings, I have a client (medical association) that has made an unusual request. They want to install a communication creature that is essentially a hybrid between a listserv and a bulletin board. We are currently running them on a CF8 server. They
-
ORA-29913: error in executing ODCITABLEDESCRIBE callout
Hi, Database is 11.2.0.3 Solaris SPARC with R 2.13.2 and ORE installed. When executing last example from page 39: http://www.oracle.com/technetwork/database/options/advanced-analytics/r-enterprise/ore-trng4-embeddedrscripts-1501638.pdf select * from
-
Duplicates and Manually Manage iPod content
Sometimes iTunes really ****** me off in some of the poor design choices that apple code designers have made. Case in point is the lack of Show Duplicates functionality on an iPod. Why is this function disabled??? Here is my problem - maybe someone h
-
Error in account determination: table T030K key ABCD JN7
Following is the error message description given by the system : Error in account determination: table T030K key ABCD JN7 Message no. FF709 T030K - Tax Accounts Determination Table JN7 - A/R CST Payable ABCD - Company Code Tax Code - A0 - 0% Output T