I have tried to do so with the nice package newfile.
But, the following code does not compile :(
\documentclass{article}
\usepackage{newfile}
\newoutputstream{outstream}
\openoutputfile{out.aux}{outstream}
\newcommand{\test}[1]
{%
\begin{writeverbatim}{outstream}
#1
\end{writeverbatim}
#1
}
\begin{document}
\test{Does it work?}
\closeoutputstream{outstream}
\end{document}
PS : If possible, I would like a LaTeX-friendly answer :)
EDIT
I got nice answers, but they don't allow me to solve in a satisfying way my problem. So, let me expose you more precisely what I would like to do.
Imagine my latex file is :
\documentclass{article}
\usepackage{my_macros}
\begin{document}
\Exercise{Bla Bla Bla}
\Solution{Bli Blu Bla}
\end{document}
I would like that the compilation of the latex file produce, as usual a .pdf file, but also two auxiliary files Exo.aux and Solu.aux that contain respectively Bla Bla Bla and Bli Blu Bla !
Thanks !
PS : If possible, I would like a LaTeX-friendly answer :) I would love to understand TeX, but although I got some answers to Online references for creating advanced macros?, I still find TeX very esoteric. I am looking for a user-friendly manual !
