Hi, I’m still
trying to get the default email program to open using open mailto: etc. After getting a 0: Event not found, when using cshOne: I figured I needed to use the bash shell. So I created (based on cshOne:) bashOne: string "Invoke
a bash-shell, pass it the string as a command and return the result
(a String)." "UnixProcess bashOne: 'ls -l'" |
cmd proc reply connection | connection := self pipeConnectionFor:
'bash' arguments:
#('') setProcessDescriptor: [:pd | proc
:= pd]. cmd :=
connection readAppendStream. [cmd nextPutAll: string; cr; commit. reply := cmd contents. proc
wait] ensure:
[cmd close]. ^reply Sadly this doesn’t work. If I copy the string as
passed in and past it into a bash shell, the mail program opens ok. I’m thinking that I need to pass some arguments to the
pipe connection, but not sure what. (I don’t unix
often). Any help greatly appreciated. Cheers, Stewart |
| I'm still trying to get the default email program to open using open
| mailto: etc. Basically one doesn't need any shell at all when you're not doing any command line tricks with redirections or pipelining. I've got a #runProcess in my repository that just invokes whatever you want directly, I'll send it to you when I'm back home (now in Monaco on a consulting gig). Though I've posted that to this here list about a year ago, you might be able to find it in the archives if you're in a hurry. Though that doesn't quite explain why your example doesn't work. The only thing I see is that you use "bash" without an absolute path, try maybe "/bin/bash". | After getting a 0: Event not found, when using cshOne: I figured I | needed to use the bash shell. Ah, hold on a sec... You aren't using things with exclamation marks in your command? The exclam is a magic thing in csh that invokes the command history and it will complain if it doesn't find something: % !foo foo: Event not found. Escape it with a $\ to disable that or put the argument in question under quotation marks. That's another problem with cshOne, since it's a shell, it reacts to all things shell. Cheers, mjl |
In reply to this post by Stew MacLean
The original cshOne: use '-t' option telling the shell to take a single command input line from standard input. I don't know if this is a possible option of bash... In your case, you have a single command to execute, the simple thing to do is to execute bash with two arguments: '-c' and 'your_mail_command_here' (the string argument). bashOne: string "Invoke a bash-shell, pass it the string as a command and return the result (a String)." "UnixProcess bashOne: 'ls -l'" | cmd proc reply connection | connection := self pipeConnectionFor: 'bash' arguments: (Array with: '-c' with: string) setProcessDescriptor: [:pd | proc := pd]. cmd := connection readStream. [reply := cmd contents. proc wait] ensure: [cmd close]. ^reply Maybe you can inquire option '-s' but I'm not sure I understood all the tricks the shell plays to connect to a tty or use the stdin instead... Nicolas Stewart MacLean a écrit : > Hi, > > > > I’m *_still_* trying to get the default email program to open using open > mailto: etc. > > > > After getting a 0: Event not found, when using cshOne: I figured I > needed to use the bash shell. > > > > So I created (based on cshOne:) > > > > bashOne: string > > "Invoke a bash-shell, pass it the string as a command and > return the > > result (a String)." > > "UnixProcess bashOne: 'ls -l'" > > > > | cmd proc reply connection | > > connection := self pipeConnectionFor: 'bash' > > arguments: #('') > > setProcessDescriptor: [:pd | proc := > pd]. > > cmd := connection readAppendStream. > > [cmd nextPutAll: string; cr; commit. > > reply := cmd contents. > > proc wait] > > ensure: [cmd close]. > > ^reply > > > > Sadly this doesn’t work. If I copy the string as passed in and past it > into a bash shell, the mail program opens ok. > > > > I’m thinking that I need to pass some arguments to the pipe connection, > but not sure what. (I don’t unix often). > > > > Any help greatly appreciated. > > > > Cheers, > > > > Stewart > |
In reply to this post by Stew MacLean
Here's the code I use in our GNUPlot parcel:
plot " Returns the output stream (a ByteArray) from running the gnuplot program. " | connection proc reply | connection := UnixProcess pipeConnectionFor: 'gnuplot' arguments: #('-persist') setProcessDescriptor: [:pd | proc := pd]. [connection output writeAll: (self plotCommand replaceAll: Character cr with: Character lf; readStream) upToEnd. connection closeOutput. reply := connection input readStream binary; upToEnd. proc wait] ensure: [connection closeOutput; closeInput]. ^reply -- Visit <http://www.GagneForMayor.com/> for the all the latest on my bid to be the next mayor of Ferndale. |
In reply to this post by Stew MacLean
Here's another, similar one with more parameters for greater flexibility:
binaryOutputFrom: aName arguments: anArgv inputStream: aStream " Create the subprocess 'aName' and pipe to its stdin the data from aStream, and return the subprocess' output as a ByteArray. If your subprocess' input stream requires special end-of-line characters, don't forget you may have to buffer replaceAll: Character cr with: Character lf before building a stream on it and passing it here. " | connection proc reply | connection := UnixProcess pipeConnectionFor: aName arguments: anArgv setProcessDescriptor: [ :pd | proc := pd ]. [ connection output writeAll: aStream upToEnd. connection closeOutput. reply := connection input readStream binary; upToEnd. proc wait ] ensure: [ connection closeOutput; closeInput ]. ^reply -- Visit <http://www.GagneForMayor.com/> for the all the latest on my bid to be the next mayor of Ferndale. |
In reply to this post by MJL-4
Hi Martin, Nicolas, and Thomas,
Thank you all for replies. I haven't had a chance to try your suggestions out on my friend's machine as yet. However, I'm thinking that I'm mistaken in thinking I need to use bash. The reason being is that I have used csh: to open the default web browser, so that must be working. Also, I think Martin has identified the problem - even though I had encoded the "url", it did contain an exclaimation mark. Which accounts for the 0: Event not found answer. I'll let you know once I get a chance to test this hypothesis. Cheers, Stewart >-----Original Message----- >From: Martin J. Laubach [mailto:[hidden email]] >Sent: 16 September 2007 8:55 p.m. >To: [hidden email] >Subject: Re: [VW 7.5] [Mac OS X] Opening default mail program using "open >mailto:...", with bash > >| I'm still trying to get the default email program to open using open >| mailto: etc. > > Basically one doesn't need any shell at all when you're not doing >any command line tricks with redirections or pipelining. I've got a >#runProcess in my repository that just invokes whatever you want >directly, I'll send it to you when I'm back home (now in Monaco on >a consulting gig). Though I've posted that to this here list about >a year ago, you might be able to find it in the archives if you're >in a hurry. > > Though that doesn't quite explain why your example doesn't work. >The only thing I see is that you use "bash" without an absolute >path, try maybe "/bin/bash". > >| After getting a 0: Event not found, when using cshOne: I figured I >| needed to use the bash shell. > > Ah, hold on a sec... You aren't using things with exclamation >marks in your command? The exclam is a magic thing in csh that invokes >the command history and it will complain if it doesn't find something: > > % !foo > foo: Event not found. > > Escape it with a $\ to disable that or put the argument in >question under quotation marks. That's another problem with cshOne, >since it's a shell, it reacts to all things shell. > > Cheers, > > mjl |
Success! As Martin suspected... the exclamation mark was the problem!
Thanks to everyone for your suggestions and help. Cheers, Stewart ! >-----Original Message----- >From: Stewart MacLean [mailto:[hidden email]] >Sent: 19 September 2007 12:54 a.m. >To: 'Martin J. Laubach'; 'nicolas cellier'; 'Thomas Gagne'; >[hidden email] >Subject: RE: [VW 7.5] [Mac OS X] Opening default mail program using "open >mailto:...", with bash > >Hi Martin, Nicolas, and Thomas, > >Thank you all for replies. I haven't had a chance to try your >suggestions out on my friend's machine as yet. > >However, I'm thinking that I'm mistaken in thinking I need to use bash. >The reason being is that I have used csh: to open the default web >browser, so that must be working. Also, I think Martin has identified >the problem - even though I had encoded the "url", it did contain an >exclaimation mark. Which accounts for the 0: Event not found answer. > >I'll let you know once I get a chance to test this hypothesis. > >Cheers, > >Stewart > >>-----Original Message----- >>From: Martin J. Laubach [mailto:[hidden email]] >>Sent: 16 September 2007 8:55 p.m. >>To: [hidden email] >>Subject: Re: [VW 7.5] [Mac OS X] Opening default mail program using >"open >>mailto:...", with bash >> >>| I'm still trying to get the default email program to open using >>| mailto: etc. >> >> Basically one doesn't need any shell at all when you're not doing >>any command line tricks with redirections or pipelining. I've got a >>#runProcess in my repository that just invokes whatever you want >>directly, I'll send it to you when I'm back home (now in Monaco on >>a consulting gig). Though I've posted that to this here list about >>a year ago, you might be able to find it in the archives if you're >>in a hurry. >> >> Though that doesn't quite explain why your example doesn't work. >>The only thing I see is that you use "bash" without an absolute >>path, try maybe "/bin/bash". >> >>| After getting a 0: Event not found, when using cshOne: I figured I >>| needed to use the bash shell. >> >> Ah, hold on a sec... You aren't using things with exclamation >>marks in your command? The exclam is a magic thing in csh that invokes >>the command history and it will complain if it doesn't find something: >> >> % !foo >> foo: Event not found. >> >> Escape it with a $\ to disable that or put the argument in >>question under quotation marks. That's another problem with cshOne, >>since it's a shell, it reacts to all things shell. >> >> Cheers, >> >> mjl > > |
I'm having problems getting VW to render glyphs, especially when using
greek, symbol and math fonts. To check, I used this code fragment from a workspace: gc := (ExamplesBrowser prepareScratchWindowOfSize: 200@600) graphicsContext. ts := TextStream on: String new. range := 16r00 to: 16rFF. 1 to: range size do: [:index | ts nextPut: (range at: index) asCharacter. (index rem: 10) = 0 ifTrue: [ts nextPut: Character cr] ifFalse:[ts nextPut: Character space]]. pS := 16. fd := (FontDescription new) family: #('symbol'); pixelSize: pS. style := TextAttributes defaultFontQuery: fd. "20% leading (the usual amount)" style lineGrid: (1.2 * pS) ceiling. ct := ComposedText withText: ts contents style: style. ct displayOn: gc at: 5 @ 5. The output I get in the scratch window is, well, quite different from what you get when looking at e.g. the character map on WinXP (c.f. the two screen shots). Does anybody have any suggestions, remedies,...??? |
In reply to this post by Stew MacLean
...the same problems crop up when working on MacOS 10.4.9, so I don't
think it's (only) platform/OS related Cheers Mike |
Free forum by Nabble | Edit this page |