Re: [Cocoadialog-users] bash script example for inputbox or standard-inputbox?
Status: Beta
Brought to you by:
sporkstorms
From: Mark A. S. <ma...@sp...> - 2005-03-02 19:43:30
|
Well, this is more of a shell question than a CocoaDialog question. It sounds like the heart of your question is regarding how to split a variable on newlines, yea? If so, something like this should work for bash (disclaimer: This may not be entirely correct, there may be better ways, etc etc. ;) I do most of my shell scripting with Perl.: OLD_IFS="$IFS" IFS=$'\n' rv=($($CD standard-inputbox --no-newline)) echo -n "User pressed: " echo ${rv[0]} echo -n "User typed: " echo ${rv[1]} IFS="$OLD_IFS" Now, note that ${rv[1]} will only contain the second line, so be sure to adjust that snippet accordingly if you want multi-line input (from the textbox for example). Also, i believe there is a bug in standard-inputbox when the --string-output is given. Hopefully i'll have time to look into it soon. (I'm just pointing it out so you don't bang your head on the desk for hours thinking your script is broken if you try to use that option). hth - mark On Mar 1, 2005, at 12:01 PM, Brad Schwie wrote: > > I haven't been able to find anything in this mailing list, the > documentation, or on the web about setting variables in a shell script > through user input. > > I'd like to be able to take user input via an inputbox or > standard-inputbox in a shell script and set a variable. Can anyone > explain to me how to do this? > > I was able to use the Perl examples for a standard-inputbox and > inputbox to set a variable, but here's my problem. The variable is > set, but the first line of the variable has the number of the button > that was pressed and then the input data (the data I really care > about) is stuck on the second line of the variable. How do I set the > variable so that just the input data is contained? Does the shell > have anyway to split data up, like Perl does? Maybe I need to use > pipes like a previous poster mentioned... Maybe I need to look at > more shell examples on the web? > > Thanks! > > Brad > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real > users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click > _______________________________________________ > Cocoadialog-users mailing list > Coc...@li... > https://lists.sourceforge.net/lists/listinfo/cocoadialog-users > |