Old 18th February 2008, 22:09   #1
RikoOnWeb
Junior Member
 
Join Date: Feb 2008
Posts: 2
Redirecting output of executed programs

Hi,

I need to redirect the output of the utility I execute during installation to a file. It's actually a conversion from UTF-16 to UTF-8 and back using iconv.exe that outputs everything to the standard output. I tried running nsExec, Exec, !System, example:
ExecWait "$\"$INSTDIR\iconv.exe$\" -f UTF-16 -t UTF-8 $\"$INSTDIR\Templates\Full page with Rewards.xml$\" > $\"$INSTDIR\Templates\Full page with Rewards2.xml$\"" $4

It never created the output file.

How can I achieve redirecting standard output to a file or if that's not possible/easy enough, what's another way to do UTF-8 to UTF-16 conversion that would allow me to redirect output to a file?

Thank you for any help
RikoOnWeb is offline   Reply With Quote
Old 19th February 2008, 08:23   #2
Mr Inches
Member
 
Join Date: Jan 2006
Location: Canberra, Australia
Posts: 76
Hi

If you want to use redirection you will probably need to run the command under a command shell, e.g.:
code:

StrCpy $R0 'cmd.exe /c "$\"$INSTDIR\iconv.exe$\" -f UTF-16 -t UTF-8 $\"$INSTDIR\Templates\Full page with Rewards.xml$\" > $\"$INSTDIR\Templates\Full page with Rewards2.xml$\""'

ExecWait $R0
Pop $4




If that doesn't work, you could build a batch file at runtime to run the appropriate command e.g.
code:

StrCpy $R0 "$TEMP\temp.cmd"

FileOpen $R1 $R0
FileWrite $R1 '$\"$INSTDIR\iconv.exe$\" -f UTF-16 -t UTF-8 $\"$INSTDIR\Templates\Full page with Rewards.xml$\" > $\"$INSTDIR\Templates\Full page with Rewards2.xml$\"'
FileClose $R1

ExecWait "cmd.exe /c $R0" $4

Delete $R0



Duncan
Mr Inches is offline   Reply With Quote
Old 19th February 2008, 09:39   #3
Takhir
Major Dude
 
Join Date: Feb 2004
Location: Moscow, Russia
Posts: 1,222
http://nsis.sourceforge.net/ExecDos_plug-in also writes to file.
Takhir is offline   Reply With Quote
Old 19th February 2008, 15:21   #4
RikoOnWeb
Junior Member
 
Join Date: Feb 2008
Posts: 2
Thanks a lot, this worked.

Quote:
Originally posted by Mr Inches
Hi

If you want to use redirection you will probably need to run the command under a command shell, e.g.:
code:

StrCpy $R0 'cmd.exe /c "$\"$INSTDIR\iconv.exe$\" -f UTF-16 -t UTF-8 $\"$INSTDIR\Templates\Full page with Rewards.xml$\" > $\"$INSTDIR\Templates\Full page with Rewards2.xml$\""'

ExecWait $R0
Pop $4




If that doesn't work, you could build a batch file at runtime to run the appropriate command e.g.
code:

StrCpy $R0 "$TEMP\temp.cmd"

FileOpen $R1 $R0
FileWrite $R1 '$\"$INSTDIR\iconv.exe$\" -f UTF-16 -t UTF-8 $\"$INSTDIR\Templates\Full page with Rewards.xml$\" > $\"$INSTDIR\Templates\Full page with Rewards2.xml$\"'
FileClose $R1

ExecWait "cmd.exe /c $R0" $4

Delete $R0



Duncan
RikoOnWeb is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump