execute

User input to the command line when using Runtime.getRuntime().exec(command);

*爱你&永不变心* 提交于 2019-12-23 09:26:20
问题 I dont think this is possible, but I have been using: Process p = Runtime.getRuntime().exec(command); to run commands on the command line, but now I have come accross a situation where the command I am running part way through will ask for some user input, for example a username. This can not be resolved by a argument to the command that is being exec, is there any way I can pass the username to the same command line instance and continue? ---EDIT--- I still cant get this to work. These are

How do you run a string as code? [duplicate]

▼魔方 西西 提交于 2019-12-23 04:28:05
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Convert String to code I have a program that needs to be able to execute a string as code. For example, I would have a string that reads: public void do(int a, int b){ a++; b--; System.out.println(a); System.out.println(b); } Now, how do I get the program to execute that string? 回答1: You can wrap this string in a class and compile it with Java Compiler API. You would have to be running JDK instead of JRE. 回答2:

c++ how to run an .exe file whose contents are stored in a char array?

余生颓废 提交于 2019-12-21 05:28:05
问题 I'm making a specific program and i just wondered if I could do this: run a file whose contents are stored in a char array ON WINDOWS. this is the code that reads the executable and stores it in a char array: filetoopen.open (C:\blahlbah.exe, ios::binary); filetoopen.seekg (0, ios::end); length = filetoopen.tellg(); filetoopen.seekg (0, ios::beg); buffer = new char [length]; filetoopen.read (buffer, length); filetoopen.close(); I heard something about RunPE and I did some searching, I haven't

SQL Procedure has no parameters and arguments were supplied

只愿长相守 提交于 2019-12-20 04:13:17
问题 So here is the code for the stored procedure and my execution. I keep getting this message when I try to execute my command: Msg 8146, Level 16, State 2, Procedure sp_LabelFilm, Line 0 Procedure sp_LabelFilm has no parameters and arguments were supplied. Any idea why? I am trying to update a column in the table tblfilm to say if a movie is short, medium, or long based on its run time. ALTER PROCEDURE [dbo].[sp_LabelFilm] AS BEGIN DECLARE @Minutes INT, @duration char(10) DECLARE Filmcursor

identify and execute php code on a string

最后都变了- 提交于 2019-12-19 10:48:27
问题 I would like to know if it's possible to execute the php code in a string. I mean if I have: $string = If i say <?php echo 'lala';?> I wanna get "<?php echo 'dada'; ?>"; Does anybody knows how? [EDIT] It looks like nobody understood. I wanna save a string like $string = If i say <?php count(array('lala'));?> in a database and then render it. I can do it using function render_php($string){ ob_start(); eval('?>' . $string); $string = ob_get_contents(); ob_end_clean(); return $string; } The

Sybase, execute string as sql query

会有一股神秘感。 提交于 2019-12-19 02:04:21
问题 In Sybase SQL, I would like to execute a String containing SQL. I would expect something like this to work declare @exec_str char(100) select @exec_str = "select 1" execute @exec_str go from the documentation of the exec command execute | exec is used to execute a stored procedure or an extended stored procedure (ESP). This keyword is necessary if there are multiple statements in the batch. execute is also used to execute a string containing Transact-SQL. However my above example gives an

Executing a Command from Java and Waiting for the Command to Finish

非 Y 不嫁゛ 提交于 2019-12-18 13:19:29
问题 In my Java program, I create a process that executes a command to run a batch file like this: try { File tempFile = new File("C:/Users/Public/temp.cmd"); tempFile.createNewFile(); tempFile.deleteOnExit(); setContents(tempFile, recipe.getText()); //Writes some user input to file String cmd = "cmd /c start " + tempFile.getPath(); Process p = Runtime.getRuntime().exec(cmd); int exitVal = p.waitFor(); refreshActionPerformed(evt); } catch (InterruptedException ex) { Logger.getLogger(mainFrame

PostgreSQL - Writing dynamic sql in stored procedure that returns a result set

百般思念 提交于 2019-12-18 11:56:02
问题 How can I write a stored procedure that contains a dynamically built SQL statement that returns a result set? Here is my sample code: CREATE OR REPLACE FUNCTION reporting.report_get_countries_new ( starts_with varchar, ends_with varchar ) RETURNS TABLE ( country_id integer, country_name varchar ) AS $body$ DECLARE starts_with ALIAS FOR $1; ends_with ALIAS FOR $2; sql VARCHAR; BEGIN sql = 'SELECT * FROM lookups.countries WHERE lookups.countries.country_name >= ' || starts_with ; IF ends_with

how to get true or false using execute() in Java Statement [duplicate]

微笑、不失礼 提交于 2019-12-17 20:32:43
问题 This question already has an answer here : Inserting preparedstatement to database - PSQL (1 answer) Closed last year . I have Statement object called stmt , Connection object conn . stmt = conn.createStatement(); boolean b = stmt.execute("INSERT INTO employee VALUES('E001', 'Smith')") But this always produce false . I want true if above query executed successfully and false if the query fails executing. How can I achieve that result using execute() method. 回答1: How can I achieve that result

Executing a jar on mac 10.8

梦想的初衷 提交于 2019-12-17 19:27:28
问题 Although this seems like a rather obvious question, I couldn't find the answer anywhere online. After I create the jar file, I can run it successfully using the command line by saying java -jar filename.jar However, I want this file to be a bit more user-friendly, in other words, run on double click. For some reason when I double click the jar file the mac jar launcher (Jar\ Launcher.app) opens, pauses one second then closes. I appreciate the help. Ps. I have made jar files through the