This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallAnywhere
- :
- InstallAnywhere Forum
- :
- Re: New Line on EXECUTE_STDOUT from Execute Script/Batch file
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Aug 28, 2008
09:25 AM
New Line on EXECUTE_STDOUT from Execute Script/Batch file
I'm using the Execute Script/Batch file action to find a value from an /etc/stuff.conf file and return the value to IA via the $EXECUTE_STDOUT$ variable.
This works, except the $EXECUTE_STDOUT$ now contains a newline. This makes using the variable useless because I cannot use the compare variables rule, nor can I use that $variable$ later in another script.
Is there a work-around on this issue?
Is there a better way to bring variables into IA from an outside source?
Thanks
This works, except the $EXECUTE_STDOUT$ now contains a newline. This makes using the variable useless because I cannot use the compare variables rule, nor can I use that $variable$ later in another script.
Is there a work-around on this issue?
Is there a better way to bring variables into IA from an outside source?
Thanks
(10) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 08, 2008
12:34 PM
Thank you very much for posting this question. I am having the exact same problem. Can someone please take a look at this and respond as soon as possible? Thank you very much, in advance, for any information that can be given regarding this problem.
Sincerely,
Mike Sucena
Software Engineer
Sincerely,
Mike Sucena
Software Engineer
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 08, 2008
02:07 PM
Could you post an example of the script and output that fail?
In a quick test on Windows, I ran dir C:\somewhere using Execute Script/Batch Files and stored the output in the default $EXECUTE_STDOUT$; afterward, I was able to display $EXECUTE_STDOUT$ in a Display Message panel, and also use $EXECUTE_STDOUT$ in a Compare InstallAnywhere Variables rule to see if it contained a string (that happened to be on the second line of output)...
In a quick test on Windows, I ran dir C:\somewhere using Execute Script/Batch Files and stored the output in the default $EXECUTE_STDOUT$; afterward, I was able to display $EXECUTE_STDOUT$ in a Display Message panel, and also use $EXECUTE_STDOUT$ in a Compare InstallAnywhere Variables rule to see if it contained a string (that happened to be on the second line of output)...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 08, 2008
02:35 PM
Robert:
This is an example of what I am trying to do.
1. I have an installer where I have an "Execute Batch/Script" action.
2. The batch/script, really just one(1) command -- but the "Execute Command" action produces the same result -- I am trying to run from a Mac OS 10.5 is hostname -s
3. I store the output from this into a variable named $MAC_MACHINE_NAME$
4. I include an "Output Debug Information" action where I display only IA variables.
5. When I look at my output file with debug information this is what I see:
.
.
.
MAC_EXTENSTIONS=
MAC_MACHINE_NAME=my_machine_name
(this is a blank line)
MAC_PREFERENCES=/Users//Library/Preferences
.
.
.
6. I then have a "Modify Text File - Single File" action where I do a "Search and Replace" strings looking for a string and replace it with the value of $MAC_MACHINE_NAME$
7. When I look at the file I modified with the action in #6 there is a new line where I found the string to replace with my $MAC_MACHINE_NAME$ variable and the rest of the line. This line is a URL connection string and I am replacing localhost:8080 with the value of $MAC_MACHINE_NAME$ and what I get in the file is http://my_machine_name(a new line, carriage return)
:8080... (this is the rest of the connection string)
Please let me know if this provides you with more information about my problem. Also let me know if you have additional questions.
Sincerely,
Mike Sucena
This is an example of what I am trying to do.
1. I have an installer where I have an "Execute Batch/Script" action.
2. The batch/script, really just one(1) command -- but the "Execute Command" action produces the same result -- I am trying to run from a Mac OS 10.5 is hostname -s
3. I store the output from this into a variable named $MAC_MACHINE_NAME$
4. I include an "Output Debug Information" action where I display only IA variables.
5. When I look at my output file with debug information this is what I see:
.
.
.
MAC_EXTENSTIONS=
MAC_MACHINE_NAME=my_machine_name
(this is a blank line)
MAC_PREFERENCES=/Users/
.
.
.
6. I then have a "Modify Text File - Single File" action where I do a "Search and Replace" strings looking for a string and replace it with the value of $MAC_MACHINE_NAME$
7. When I look at the file I modified with the action in #6 there is a new line where I found the string to replace with my $MAC_MACHINE_NAME$ variable and the rest of the line. This line is a URL connection string and I am replacing localhost:8080 with the value of $MAC_MACHINE_NAME$ and what I get in the file is http://my_machine_name(a new line, carriage return)
:8080... (this is the rest of the connection string)
Please let me know if this provides you with more information about my problem. Also let me know if you have additional questions.
Sincerely,
Mike Sucena
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 08, 2008
02:39 PM
Robert Dickau,
I found both Linux/Windows scripts/bats actions behaved the same. Your sample description is correct, but the missing part is the "newline" in the $EXECUTE_STDOUT$.
Try this:
- After your Script/Bat action,
- add a "scrolling message" panel
- have it print: stdout=$EXECUTE_STDOUT$==
You would expect the panel to show:
stdout=myoutput==
Instead, it will show:
stdout=myoutput
==
The bad part about the newline added to the value is if you want to use the $EXECUTE_STDOUT$ in another script/bat action.
The linux line:
if [ -f $EXECUTE_STDOUT ]; then
Becomes:
if [ -f myoutput
]; then
Linux (and windows) will choke on this. Yuck.
I found both Linux/Windows scripts/bats actions behaved the same. Your sample description is correct, but the missing part is the "newline" in the $EXECUTE_STDOUT$.
Try this:
- After your Script/Bat action,
- add a "scrolling message" panel
- have it print: stdout=$EXECUTE_STDOUT$==
You would expect the panel to show:
stdout=myoutput==
Instead, it will show:
stdout=myoutput
==
The bad part about the newline added to the value is if you want to use the $EXECUTE_STDOUT$ in another script/bat action.
The linux line:
if [ -f $EXECUTE_STDOUT ]; then
Becomes:
if [ -f myoutput
]; then
Linux (and windows) will choke on this. Yuck.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 08, 2008
02:50 PM
Mike Sucena,
If you're looking for code snippet, I ended up using an Execute Custom Code action with the following code (snippet):
public void install( InstallerProxy ip ) throws InstallException
{
String myString = (String)ip.getVariable( "$EXECUTE_STDOUT$" );
String newline = System.getProperty("line.separator");
myString = myString.replaceAll(newline, "");
// String[] poList = pos.split("\r\n|\r|\n");
ip.setVariable("$EXECUTE_STDOUT$", myString);
}
Start off by using a custom action template
compile the code (don't forget to include the IAClass.zip)
Insert this action _after_ your script/bat action
Set a variable (single variable) to a variable you want to preserver.
You may want to set the "evaluate variables at assignment" toggle.
HTH
If you're looking for code snippet, I ended up using an Execute Custom Code action with the following code (snippet):
public void install( InstallerProxy ip ) throws InstallException
{
String myString = (String)ip.getVariable( "$EXECUTE_STDOUT$" );
String newline = System.getProperty("line.separator");
myString = myString.replaceAll(newline, "");
// String[] poList = pos.split("\r\n|\r|\n");
ip.setVariable("$EXECUTE_STDOUT$", myString);
}
Start off by using a custom action template
compile the code (don't forget to include the IAClass.zip)
Insert this action _after_ your script/bat action
Set a variable (single variable) to a variable you want to preserver.
You may want to set the "evaluate variables at assignment" toggle.
HTH
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 08, 2008
03:18 PM
Likewise, for the time being I was going to suggest an action like this using the trim method:
import com.zerog.ia.api.pub.*;
public class TrimVariableValue extends CustomCodeAction
{
public void install(InstallerProxy ip) throws InstallException
{
ip.setVariable("EXECUTE_STDOUT",
ip.substitute("$EXECUTE_STDOUT$").trim( ));
}
public void uninstall(UninstallerProxy up) throws InstallException { /* do nothing */ }
public String getInstallStatusMessage( ) { return "Trimming..."; }
public String getUninstallStatusMessage( ) { return ""; }
}
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 08, 2008
04:07 PM
Bob & Robert:
Thank you very much for your suggestions. I was able to accomplish what I was trying to do with a Custom Code Action using the .trim() method. I appreciate your assistance.
I am wondering why something so simple requires custom coding? Do you think this may be a bug? Or is accomplishing something like this only possible with Custom Coding? I'm just curious because this doesn't sound like something you would need custom coding for. Please let me know what you think. Again, thank you for all your cooperation in this matter.
Sincerely,
Mike Sucena
Thank you very much for your suggestions. I was able to accomplish what I was trying to do with a Custom Code Action using the .trim() method. I appreciate your assistance.
I am wondering why something so simple requires custom coding? Do you think this may be a bug? Or is accomplishing something like this only possible with Custom Coding? I'm just curious because this doesn't sound like something you would need custom coding for. Please let me know what you think. Again, thank you for all your cooperation in this matter.
Sincerely,
Mike Sucena
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 09, 2008
06:54 AM
Mike,
I was wondering the same exact thing. I quit wondering, wrote the custom code and moved on... but I have to admit, I keep wondering why have the newline?
Here's another funny thing I discovered about this newline business:
- assign $myvar$ = $EXECUTE_STDOUT$
- use the Get User Input advanced user panel
- and a textfield with:
- the default value: $myvar$
- the result value: $myvar$
- print "myvar=$myvar$==" in a scrolling message pane
- (or debug output)
You'll see the textfield displays the value of myvar _with_ a blank space on the end (where the newline used to be).
Because of the re-assignment of $myvar$ (via the result value in the textfield), $myvar$ no longer has a newline, but a space.
This isn't a work-around - only an observation.
I was wondering the same exact thing. I quit wondering, wrote the custom code and moved on... but I have to admit, I keep wondering why have the newline?
Here's another funny thing I discovered about this newline business:
- assign $myvar$ = $EXECUTE_STDOUT$
- use the Get User Input advanced user panel
- and a textfield with:
- the default value: $myvar$
- the result value: $myvar$
- print "myvar=$myvar$==" in a scrolling message pane
- (or debug output)
You'll see the textfield displays the value of myvar _with_ a blank space on the end (where the newline used to be).
Because of the re-assignment of $myvar$ (via the result value in the textfield), $myvar$ no longer has a newline, but a space.
This isn't a work-around - only an observation.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Sep 22, 2009
12:47 PM
I assume there is still no trim action?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jul 29, 2020
03:20 AM
Hi,
I trimmed linebackers in linux (centos) using
| tr -d '\n'
before it got into EXECUTE_STDOUT like that:
cat /tmp/samplefile.txt | grep searchstring | cut -d "," -f4 | tr -d '\n'
Worked for me