[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Multiple lines on system call from SQR



Franck (& Terry),

My first thought was the same as yours, but when I reread the question I
realised Terry wants to know how to do statements that are normally
expressed on multiple lines (ie 'for loop' or 'if then').

The trick seems to be to imbed linefeed characters (displayed as ^J) within
the command string.  eg,

  if [ $TERM = vt100 ]^Jthen^Jecho 'yes'^Jelse^Jecho 'no'^Jfi

I haven't done it in sqr but I assume you could use 'encode' or even
possibly enter it directly in the string if your editor (and the sqr
compiler) permits.

If for some reason that doesn't work I would go with your other idea of
writing an external shell script.  To address your question of how you find
it, the answer is you write it on the fly (from your sqr) and put it where
you want (probably somewhere like /tmp).  After you execute it you can
remove it (or not, as the operating system would remove it from there
eventually anyway).

Wayne Ivory
Information Services
Westralian Sands Limited


-----Original Message-----
From: Franck Masson [mailto:SQR-USERS@list.iex.net]
Sent: Saturday, 22 May 1999 3:57
To: SQR-USERS@list.iex.net; franck.masson@SQRIBE.COM
Subject: Re: Multiple lines on system call from SQR


Terry,

on unix you can execute multiple command on the same line.
Example :
ls -al; cd /tmp; cp /etc/hosts hosts.copy
or
(ls -al; cd /tmp; cp /etc/hosts hosts.copy) 1>/tmp/output 2>/tmp/error
 there is a lot of choice

franck,

Terry Cheung. wrote:
>
> Hi,
>
> I am developing in SQR v4 on UNIX
>
> I want to run some UNIX commands from SQR by using system call.
> Two questions I hope you can assist:
> 1)      How can I run multiple line unix commands from SQR? I know we can
> run single line commands like e.g.   let $cmd =  'mkdir newdirectory'
>                call system $cmd #rc
>         but when using 'for loop' or 'if then' how is this done?
>
> 2)      Alternatively I could write an external shell script and then
using
> call system to execute it, but how do I ensure that the SQR during runtime
> can find the shell script(without me hardcoding the path)?
>
> Thanks in advance
> Terry Cheung - Bertelsmann mediaSystems
> BMG Distribution, Unit 24 Crystal Drive, Warley, West Midlands, B66 1QG,
> United Kingdom.
> * terry.cheung@bmg.co.uk
> * terry.cheung@bertelsmann.de
> * Tel: +(44)-121-543-4276
> * Fax: +(44)-121-543-4393