# Piping StandardForm from within GUI

I am working on a GUI project where I need to pipe a string I constructed in Mathematica into an external program. For example

s="This
is a
string.";
StandardForm[s]>>"!cat";


which prints as expected

This
is a
string.


into the terminal. However, if try to do the same from within the GUI, (in this case triggered by a button click)

Needs["GUIKit"];
GUIRun[
Widget["Button",{
BindEvent["action",Script[
s="This
is a
string.";
StandardForm[s]>>"!cat";
]]}]]


the following shows up in the terminal:

"This\nis a\nstring."


which is the InputForm of s. Clearly this is a problem if the external program is not cat and expects properly formatted input.

What is happening here?

I am running Mathematica 10.1 on Ubuntu 14.04 (64 bit).

## Update:

I found a workaround by calling a wrapper function which was defined in Global.

Needs["GUIKit"];
PipeIt[inp_,com_]:=Block[{},StandardForm[inp]>>"!"<>com];
GUIRun[
Widget["Button",{
BindEvent["action",Script[
s="This
is a
string.";
PipeIt[s,"cat"];
]]}],
IncludedScriptContexts -> "Global"]


But I still don't understand what causes the problem.

• As nobody has commented so far, I assume I dont't make an obvious mistake. Is this a bug? – murphy Aug 6 '15 at 10:39
• There is no comment because GUIKit not developed and not many folks are familiar with it. Sometimes related questions are answered due to the fact that the problem is in fact a Java one. – Kuba Aug 6 '15 at 14:53
• Is there any reason you are using GUIKit instead of for instance CreateDialog? – Karsten 7. Aug 6 '15 at 17:14
• No particular reason. Is CreateDialog` intended/suitable for complex GUIs? – murphy Aug 6 '15 at 19:58