[Tuglist] Multimedia & pdfTeX

Radhakrishnan CV tuglist@tug.org.in
17 Aug 2002 09:36:51 +0530


>>>>> "Rai" == H S Rai <hsraidce@iitr.ernet.in> writes:

    Rai> Today at 10:08am +0530 Radhakrishnan CV wrote:

    >> \href{run:editmyfile.sh}%
    >> {\fboxsep5pt\fboxrule1pt\color{red}\shadowbox{Edit this file}}

    Rai> I was able to use it when shell script file is there in
    Rai> proper place. How to creat it on the fly? 

\newwrite\tmpout % we define an output stream

\def\editdoc#1#2#3{\immediate\openout\tmpout=#2
%
% we open a file as provided in #2 to write out shell commands
%
  \immediate\write\tmpout{\string\xterm\space -e vi #1}
%
% we use \xterm in case you have an alias for 'xterm'
%
  \immediate\closeout\tmpout
%
% we close the output stream
%
   \href{run:./#2}%
   {\fboxsep5pt\fboxrule1pt\color{red}\shadowbox{#3}}
 \immediate\write18{chmod +x #2}}
%
%  shell escape command to change the execute bit of the script

The usage will be:

 \editdoc{<file to be edited>}{<shell script name>}{<clickable link text>}

\editdoc{manual.tex}{edit.sh}{Edit this file}

Similarly, you can define \playmovie, \playsound to launch appropriate
applications available in your system. This should work in all the web2c
implementations (ie., teTeX or TeXLive) across different operating
system. Of course, Win32 systems need gnutools/cygwin installed for
this to work and Mac OS X is now unix. 

    Rai> Is above line for on the fly? Is "editmyfile.sh" and "Edit
    Rai> this file" same in above line?

The above macro explains.

    Rai> I tried taking both same, which resulted in "undefined
    Rai> control sequence error"

Seems like you haven't loaded hyperref.sty for this to work. \href is
a function defined in hyperref.

-- 
Radhakrishnan