Bash: push a string on input
I want to try to put a file manager in PROMPT_COMMAND, where e.g. you choose some files, press F6, and the top-level, interactive prompt then shows
$PS1 mv \
/tmp/file1 \
/tmp/file2 (space)
Kind of like read -e -i "ls "; eval $REPLY
So far I thought of two solutions:
xsel -x
echo -n "$filemanager_output" | xsel -i
xdotool key --clearmodifiers Shift+Insert
xsel -x
This may paste things out of the window (if you're quick)
(+edit) It won't work if the mouse isn't on the window.
And using screen:
echo -n "$filemanager_output" > /tmp/filemanager_output
(screen escape) readreg a /tmp/filemanager_output
(screen escape) paste a
But then screen is a requirement.
I couldn't find a bash built-in or readline command to do this, maybe I missed it?
What do you think of the above solutions? Too "hackish"?
Last edited by Procyon (2010-02-04 17:36:19)
Read the networking tutorial:
[http://java.sun.com/docs/books/tutorial/networking/sockets/index.html]
Kaj
Similar Messages
-
I have an iPod Video. (30GB 5th gen) The headphone jack only works if I push the headphone cable input to one side and hold it t here. If I leave it alone it either doesnt play at all or I hear a crackling sound. Any suggestions? Thanks.
There are threads ongoing on similar topics. This is not a suitable topic for this forum.
I will pass on any comments from the other threads and original post in this one, but I'm closing this topic and any further petitions like this as it will just result in "Creative-bashing" and unproducti've comments.
Cat -
Example string as input, representing a date, MM/DD/YYYY
Please give an example the program that takes a String as input from the keybord (I have to use the Scanner method and i have already created it) , representing a date
Please tell me how to do it that including how to write leap year logic. (I'm expecting that i need to use IF/ELSE becuse i need to validate day, month ,year whether they are valid or not)
Here is an example of an execution:
Enter the date: 1/1/00 // input that is put from user (I have to use the scanner method)
Your date is: January 1, 2000 // this output i want to come out (it changed 1 into January)
I'm so sorry. I'm totally new in Computer Science. now i know how to use if/else in int,double, but i don't know how to do with String.
ThanksAvoid multi post
http://forum.java.sun.com/thread.jspa?threadID=5223112 -
What is the little square box in the string constant input?
Hello LabVIEW World -
I am attempting to understand a LabVIEW code that I did not write. At one point, there is a string (Equal?) comparison that is comparing a string from a VISA Read to a string constant input. The string constant has a little square box inside of it.
Does anyone know what this little square box is? (See attached screenshot)
Thanks.
DS
Attachments:
LittleSquare.JPG 69 KBWhen I place string constants like this I will display then either as hex or in the codes mode. Either of these will make the code more readable. Using the default ASCII string display is useless other than letting you know it is an unprintable character.
Mark Yedinak
"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot -
Array of String for input paramter + dynamic invocation
Does anybody know a place I can find an example of web service
using the following methods:
1. Array of String as input parameter
2. Client uses dynamic invocation
Specifically, 1. how do I define the parameter type in web-services.xml?
2. how do I refer to the type in a client code?
Thanks,
HongHello,
The doclitparam interop round 3 example does a echo string array.
http://dev2dev.bea.com/managed_content/direct/webservice/r3server.zip
Also there is a DII example in the WebService Wizard's archive:
http://dev2dev.bea.com/managed_content/direct/webservice/wswa.html#qz29
HTH,
Bruce
Hong wrote:
Does anybody know a place I can find an example of web service
using the following methods:
1. Array of String as input parameter
2. Client uses dynamic invocation
Specifically, 1. how do I define the parameter type in web-services.xml?
2. how do I refer to the type in a client code?
Thanks,
Hong -
XML String as input parm for WS?
Hi All.
This has probably been asked and answered a few times, but I can't seem to find a exact answer to my scenario:
I have a java method that accepts a string as a input parm. However, the string will contain a fully formatted XML string eg:
<?xml version=\"1.0\" standalone=\"yes\"?>
<CAMPUS_UPD>
<MSG_SEQ_NO>NATX_00000000000000200609141569398</MSG_SEQ_NO>
<EVENT_NAME>CAMPUS_UPD.UPD</EVENT_NAME>
<STATUSCODE>000</STATUSCODE>
<CAMPUS_KODE>01</CAMPUS_KODE>
<CAMPUS_NAME>STELLENBOSCH</CAMPUS_NAME>
</CAMPUS_UPD>
I'm basically going to put this XML string directly onto a InterConnect AQ Table for consumption by Interconnect.
Now naturally I get a VERY strange set of errors when I actually try to call the WS with this XML String.
<HTML><HEAD><TITLE>Web Service</TITLE></HEAD><BODY><H1>Bad Request</H1><PRE>Error parsing envelope: (4, 30) PI with the name 'xml' can occur only in the beginning of the document.</PRE></BODY></HTML>
If I remove the first line of the XML string, the error message changes to:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="http://sun.oic.ws/types/"><env:Body><env:Fault><faultcode>env:Client</faultcode><faultstring>caught exception while handling request: deserialization error: unexpected XML reader state. expected: END but found: START: KAMPUS_UPD</faultstring></env:Fault></env:Body></env:Envelope>
Any Ideas/suggestions/wild speculations/URL's etc.
Kind Regards
Elmar Matthee
University of Stellenbosch
South AfricaHi Eric/all.
Just thought I'd give a follow up on my progress.
Got the web services working and finally able to test via Jdev. Seems the problem was with the proxy server settings of jdeveloper itself. I had localhost specified as an ip NOT to use a proxy server for, but when the test code got generated it used the actual ip of my machine (where the application server is also running) to access the web service, and thats where it got stuck.
I actually sent along the embedded xml string in a string parameter directly to the the web service, and it worked like a charm (as opposed to testing it via the application server administration web page where I had to translate the < and > characters. So quite chuffed with that.
Today I'm researching a) What happens when you have a complex data type (i.e. a java class containing 3 fields like username/fullname/age) from a web service. When I test it via the application server web page, I get the actual fields with their names and values in an xml type format back, but when I test it via java, i get a reference to the object. Now I could cast the result back into the class definition that I used when creating the web service, but what if I don't know what that is (i.e. someone else somewhere wrote the WS, and I have no idea about implementation)?
b) related to a) is how to convert the complex data type return value into an XML string before sending the reply (or maybe even a pure String containing the XML data). I.e. instead of sending a Person class, I send back an XML data type containing the relevant data with tags and all. I'm a bit worried about this, because it looks as if the data is alreaddy actually coming back in an XML format, its just that the java test program doesn't see it that way, and I'm loath add the extra overhead if it isn't needed.
c) related to both a) and b). How the @$#@ does one actually use/call a web service in a simple .jsp page? Seemingly a simple question, but thus far, the answer eludes me. :)
Any thoughts/comments/ideas/wild speculations/urls welcome.
Kind Regards.
Elmar -
How to encrypt with a string as input,but not a key object
As far as I know,when encrypt or decrypt ,a key must first be got,and the key is first generate by a tool or from SecurityRandom,that means I can not generate the same key with the same input.Does there is a method which can generate a same with the same input string?
There is a need to transfer file between to site,and the customer wish to encrypt these files during transfering,and they want to store a string into each database at each site,when sending and receiving files,get the string from the database to encrypt or decrypt the file,they alse want to have a control of the string,they can change the string randomly if they wish as long as long keep each string is equal,how to realize this?I think what you are looking for is a password based encryption (PBE). An example of using the same is mentioned in JCE reference guide. Below is the relevant code/docs from the rference guide.
Using Password-Based Encryption
In this example, we prompt the user for a password from which we derive an encryption key.
It would seem logical to collect and store the password in an object of type java.lang.String. However, here's the caveat: Objects of type String are immutable, i.e., there are no methods defined that allow you to change (overwrite) or zero out the contents of a String after usage. This feature makes String objects unsuitable for storing security sensitive information such as user passwords. You should always collect and store security sensitive information in a char array instead.
For that reason, the javax.crypto.spec.PBEKeySpec class takes (and returns) a password as a char array.
The following method is an example of how to collect a user password as a char array:
* Reads user password from given input stream.
public char[] readPasswd(InputStream in) throws IOException {
char[] lineBuffer;
char[] buf;
int i;
buf = lineBuffer = new char[128];
int room = buf.length;
int offset = 0;
int c;
loop: while (true) {
switch (c = in.read()) {
case -1:
case '\n':
break loop;
case '\r':
int c2 = in.read();
if ((c2 != '\n') && (c2 != -1)) {
if (!(in instanceof PushbackInputStream)) {
in = new PushbackInputStream(in);
((PushbackInputStream)in).unread(c2);
} else
break loop;
default:
if (--room < 0) {
buf = new char[offset + 128];
room = buf.length - offset - 1;
System.arraycopy(lineBuffer, 0, buf, 0, offset);
Arrays.fill(lineBuffer, ' ');
lineBuffer = buf;
buf[offset++] = (char) c;
break;
if (offset == 0) {
return null;
char[] ret = new char[offset];
System.arraycopy(buf, 0, ret, 0, offset);
Arrays.fill(buf, ' ');
return ret;
}In order to use Password-Based Encryption (PBE) as defined in PKCS #5, we have to specify a salt and an iteration count. The same salt and iteration count that are used for encryption must be used for decryption:
PBEKeySpec pbeKeySpec;
PBEParameterSpec pbeParamSpec;
SecretKeyFactory keyFac;
// Salt
byte[] salt = {
(byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c,
(byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99
// Iteration count
int count = 20;
// Create PBE parameter set
pbeParamSpec = new PBEParameterSpec(salt, count);
// Prompt user for encryption password.
// Collect user password as char array (using the
// "readPasswd" method from above), and convert
// it into a SecretKey object, using a PBE key
// factory.
System.out.print("Enter encryption password: ");
System.out.flush();
pbeKeySpec = new PBEKeySpec(readPasswd(System.in));
keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);
// Create PBE Cipher
Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");
// Initialize PBE Cipher with key and parameters
pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);
// Our cleartext
byte[] cleartext = "This is another example".getBytes();
// Encrypt the cleartext
byte[] ciphertext = pbeCipher.doFinal(cleartext);Hope this helps
Sai Pullabhotla -
String control input charecter to upcase charecter?
Is there any property or method in string control that can modify input character to upcase character?
Solved!
Go to Solution.reading between the lines on your post (because there's not enough information to say for sure), it looks like you want to have a string control on your front panel and if a user types a lower case character you'd replace it real-time with the uppercase equivalent? Is it good enough to convert to uppercase after they hit enter or move to a different control?
If it needs to be done as soon as the key is pressed, have a look at the attached. One easy-to-overlook thing is "update value while typing" setting (right click on front panel string control).
Attachments:
all_caps.vi 7 KB -
Is it possible to pass array of strings as input parameters for stored proc
Dear All,
I wrote a Stored Procedure for my crystal report. now i got a modification.
one of the parameters 'profit_center' should be modified so that it is capable to take multiple values.
now when i run report crystal report collects more than one values for parameter profit_center and sends it as input parameter to stored procedure all at a time.
the only way to handle this situation is the input parameter for stored procedure 'profit_center' should be able to take array of values and i have a filter gl.anal_to = '{?profit_center}'. this filter should also be modified to be good for array of values.
Please Help.Or you can use sys.ODCIVarchar2List
SQL> create or replace procedure print_name( In_Array sys.ODCIVarchar2List)
is
begin
for c in ( select * from table(In_Array) )
loop
dbms_output.put_line(c.column_value);
end loop ;
end ;
Procedure created.
SQL>
SQL> exec print_name(sys.ODCIVarchar2List('ALLEN','RICHARD','KING')) ;
ALLEN
RICHARD
KING
PL/SQL procedure successfully completed.SS -
String[] in input , how to manage with foreach block?
hi,
my situation is this :
i invoke a web service which has a array of string (String[] ) in output , i was thinking to manage it with a foreach block, invoking a second web service able to read the single strings..
the first block is the invoke to a web service 1 that returns me $InvokeWS1_uotputVariable/return, which value is the array String[]
in the foreach block i have start value 1 and finale value : count($InvokeWS1_outputVariable.parameters/return)
than i'm trying to manage every string with the invocation to webservice 2 inside the foreach block , which will read it., i assign it a single string using an assign block with this assignement :
$InvokeWS1outputVariable.parameters/return[$foreach1Counter] associated with $InvokeWS2inputVariable.parameters/arg0.
the problem is that inside the foreach statement every invocation to the second web service gets only the first element in the array.
Anyone knows if i managed it correctly?This blog post of mine uses for each- http://blogs.sun.com/malkit/entry/dynamic_services_composition_in_bpel. Please take a look at the attached project.
If you still have some questions, please let us know.
- Malkit S. Bhasin -
How can detect certain text (String) was input in a JTextArea?
Hi friends,
while trying to simulate a telnet shell, i create a JTextArea and put all the input and output text (from telnet) in it. I want to do some info updating in another JPanel when user logs in. Hence I need to detect if user correct logged in, say, a prompt will appear in JTextArea, such as :
[remote host]>
I need here a Listener for detecting, could someone tell me how i can do it, or which Class or Interface or Methods i should use? Many thanks in advance!!!
eedychI found something that I hope helps:
The java.awt.TextArea could be monitored for changes by adding a TextListener for TextEvent's. In the JTextComponent based components, changes are broadcasted from the model via a DocumentEvent to DocumentListeners. The DocumentEvent gives the location of the change and the kind of change if desired.
Example code :
DocumentListener myListener = ??;
JTextArea myArea = ??;
myArea.getDocument().addDocumentListener(myListener);
Just use the DocumentListener like any other listener. :) Good luck. -
Trying to create a latching push button using digital inputs
Hi everyone,
I'm writing a program to control a motor with 3 push buttons, Up, Down and Stop. I want the Up button to latch when pushed and delatch when Stop or Down are pushed. I've tried the Resettable Latch.vi example program from this website but no luck. It seems like the output from the AND gate is indeterminate. I've attached my program, Any help would be great! Thanks
Solved!
Go to Solution.
Attachments:
LatchAttempt.vi 140 KBUse Index Array to get the single boolean you want from the array. If you don't wire an index it will give you element 0. Using this you could have all the switches wired to different pins of the same register on your DAQ device. Then you could read one byte and sort out which bit does what. You also need to build the individuale booleans into an array before writing to the DAQ. Here's a quick example:
You need to decide which button sets which bit. I haven't checked the logic of your latch algorithm yet.
Kelly Bersch
Certified LabVIEW Developer
Kudos are always welcome -
[SOLVED][BASH] Using a string to pass multiple arguments.
I'm scratching my brain on this little project my friend roped me into.
I have a function which generates a list of VM's and their states and stores it as a variable. this list is to be presented to the user using the libgui.sh 'ask_option' function. The problem is that the ask_option function does not interpret it correctly. And by saying ask_option isn't doing it right I mean I am expecting a certain behavior, and that expectation is flawed.
Here are the two parts in question
#assume VMLIST has a value identical to this assignment after my function call:
#I have confirmed that this is the exact value
VMLIST="\"Arch Linux Live\" \"running\" \"Windows XP\" \"power off\""
ask_option 0 "VMs Present" '' optional "0" "Return to the Main Menu" $VMLIST
What I actually get shows that ask_option is interpreting each discreet word as an argument. whereas I want the argument to be the text between each quote
0 Return to Main Menu
"Arch Linux
Live" "running"
"Windows XP"
"power off"
Obviously what I want is a two column output in the dialog that resembles
0 Return to Main Menu
Arch Linux Live running
Windows XP power off
What should our approach be to rectify this? How can I use the variable to suppply discreet arguments to another function? or rather how can I have the value of the variable interpreted literally on the function call line?
Last edited by OrionFyre (2011-04-05 19:04:49)ARRAYS! I knew that
Thanks scary face kitteh!
I should have remembered arrays. alas. that's what happens when you don't use it for a while. -
RKD_WORD_WRAP with string input
hi all,
I need to split a string with RKD_WORD_WRAP, but it seems it takes only chars as input, so I would like to do this: create a char variable dynamically as long as the string in input and then pass it to the RKD_WORD_WRAP. Can anybody please tell me how can I do it? I think I should use field symbol but I don't know them very much.
Thanks in advance.
GabrieleJ@Y wrote:
> RKD_WORD_WRAP has a limitation to split at a maximum of 3 lines..I wanted you to know about it before proceeding...
I used in this way with no lines but table for result for testing:
DATA the_string(300) TYPE c VALUE 'Nel mezzo del cammin di nostra vita mi ritrovai per una selva oscura ché la diritta via era smarrita. Ahi quanto a dir qual era è cosa dura 5 esta selva selvaggia e aspra e forte che nel pensier rinova la paura! '.
CALL FUNCTION 'RKD_WORD_WRAP'
EXPORTING
textline = the_string
DELIMITER = ' '
OUTPUTLEN = 15
TABLES
OUT_LINES = text_table
with this output
Nel mezzo del
cammin di
nostra vita mi
ritrovai per
una selva
oscura ché la
diritta via
era smarrita.
Ahi quanto a
dir qual era è
cosa dura 5
esta selva
selvaggia e
aspra e forte
che nel
pensier rinova
la paura!
so it works with many lines as need: they're just put in the table
now I'll check for split_string FM working ... -
I'm new in Java. I used to be C programmer. I cannot find such method which can handle some input like scanf( ) in C. Is there any? If any, please some one tell me. I'm trying to build an interactive console application with Java, I know it is possible but i dont know how. I've tried using System.in.read(), but i'm confused how to use this method.
There's no scanf() like here in java, if you want to an input from a console you need to do it by yourself....
The above code is one example and here's another one:
import java.io.*;
public class test
public static void main(String a[])
try {
DataInputStream input = new DataInputStream(System.in);
System.out.println ("Enter a String: ");
String str=input.readLine();
System.out.println ("Your string: "+str);
catch (Exception ex) {
[code/]
Maybe you are looking for
-
IPhone 5s having weird issues...anyone have this too??
Hello(: So I've had the iPhone 5s ever since the release and around the first week I noticed it randomly restarted itself but everything was working properly so I let it slide by. However, ever since then my phone would freeze on what ever app/screen
-
While creating PO i am getting an error message as purchase org. not respon
Hi, After assigning return order type to plant when i am trying to create PO it is giving me error as "Purchase org. not responsible for plant" Is it because of some assignment missing?if ,yes than what is a navigation path. if,no then which assignme
-
Windows XP installation on new machines
Hey, anybody knows if the latest Toshiba machines support Windows XP installation, or it is commonly accepted to support only Windows 7 and later OS? I tried to install Windows XP Pro SP3, 2008 release on Satellite C660 machine released in 2011, and
-
Error occurred during character conversion in SXMB_MONI
Hello Experts, Good Day! I would like to seek your help here. When i used tcode SXMB_MONI to search for messages i get this error : Error occurred during character conversion. So far no problem with the program. Its work for all other dates. Just for
-
Titan Z GPU Compatibil​ity with a D20
I have a D20 4155 with and Xeon X5687 single processor and 12 MB RAM. I currently have a Quadro 4000 Video Card installed. I create flow simulations that are extremely math intensive and can take days to complete relying only on the CPU. I am loo