Home  
Login
Username:

Password:

Remember me



Lost Password?

Register now!
Sections
Who's Online
78 user(s) are online (64 user(s) are browsing Forums)

Members: 0
Guests: 78

more...
Support us!
Recent OS4 Files
OS4Depot.net





AREXX question
Home away from home
Joined:
2006/11/26 21:45
From A haunted Castle somewhere in the Bavarian Mountains
Posts: 2986
I'd like to pull something off with AREXX but doesn't seem toi get it tow ork the way i want.

Here's the thing...i know about opening/reading/writing of files in AREXX, but can i catch output from an externally started program wihout the need of those file I/O?

This is what i'd like to achive:

test=ADDRESS COMMAND "version"

The above is just an example.

I don't think this is possible, but please prove me wrong.

I played around with quotation marks, but it doesn't seem to execute the command, unless i leave out the test= part, but then output obviously goes into console.

Is it possible in AEXX (maybe with a workaround or trick) or do i have to go the file I/O way either way?
I want to produce as less overhead as possible as this script should go (if it ever works) into network startup, so it shouldn't do too much I/O to keep the error margin as small as possible.

Thanks

_________________
If slaughterhouses had glass walls, everyone would be a vegetarian. ~ Sir Paul McCartney
-
Did everything just taste purple for a second? ~ Philip J. Fry
-
Ain't got no cash, ain't got no style, ladies vomit when I smile. ~ Dr. John Zoidberg
   Report Go to top

Re: AREXX question
Not too shy to talk
Joined:
2006/11/26 17:45
Posts: 266
@Raziel

/* rexx */

address command
'version >ram:version.txt'

if Open(in,"ram:version.txt",readthen do
   
test ReadLn(in)
   
call Close(in)
end

say 
"version = <"test">"



   Report Go to top

Re: AREXX question
Home away from home
Joined:
2006/11/26 21:45
From A haunted Castle somewhere in the Bavarian Mountains
Posts: 2986
@thomas

Thank you, but that is exactly what i'm trying to avoid.

With your script a textfile is created, opened and then left.

I could delete it afterwards, but i explicitely don't want to create a file.

_________________
If slaughterhouses had glass walls, everyone would be a vegetarian. ~ Sir Paul McCartney
-
Did everything just taste purple for a second? ~ Philip J. Fry
-
Ain't got no cash, ain't got no style, ladies vomit when I smile. ~ Dr. John Zoidberg
   Report Go to top

Re: AREXX question
Just can't stay away
Joined:
2006/12/1 18:01
From Copenhagen, Denmark
Posts: 1048
@Raziel

Realistically, writing and reading a file in RAM: is not going to be noticable in terms of overhead, and it is the most normal solution for this, but I get your point.

An alternative which might seem a bit more clean (if you don't look behind the scenes) is to use C:RxSet and the ARexx GetClip() function.

Best regards,

Niels

   Report Go to top

Re: AREXX question
Not too shy to talk
Joined:
2006/12/6 19:36
Posts: 432
@Raziel

I know you would like to do it with ARexx, but is it something you could achieve with a DOS Script too?

   Report Go to top

Re: AREXX question
Home away from home
Joined:
2006/11/26 21:45
From A haunted Castle somewhere in the Bavarian Mountains
Posts: 2986
@Amigo1

Of course, all hints welcome

@nbache

Have to read up on RxSet then, never used that command

Thanks to both of you

_________________
If slaughterhouses had glass walls, everyone would be a vegetarian. ~ Sir Paul McCartney
-
Did everything just taste purple for a second? ~ Philip J. Fry
-
Ain't got no cash, ain't got no style, ladies vomit when I smile. ~ Dr. John Zoidberg
   Report Go to top

Re: AREXX question
Just can't stay away
Joined:
2008/1/6 17:56
From Pennsylvania, USA
Posts: 1268
@Raziel
Not exactly sure what you want but in an AmigaDOS script you can do this:

;AmigaDOS script
Set vers `version`
echo $vers

Note that the characters that look like single quotes are actually the character in the key to the left of the 1 key on most keyboards. The key has a ~ char with a ` char below it.



_________________
Amiga X1000 with 2GB memory & OS 4.1FE + Radeon HD 5450

   Report Go to top

Re: AREXX question
Home away from home
Joined:
2006/11/26 21:45
From A haunted Castle somewhere in the Bavarian Mountains
Posts: 2986
@xenic

The version was just an example.

What i want to achieve is reading in a fraction of a website with cURL and process that further on in the AREXX script, but without the need of saving the string to a file first.

But i guess it's not possible.

_________________
If slaughterhouses had glass walls, everyone would be a vegetarian. ~ Sir Paul McCartney
-
Did everything just taste purple for a second? ~ Philip J. Fry
-
Ain't got no cash, ain't got no style, ladies vomit when I smile. ~ Dr. John Zoidberg
   Report Go to top

Re: AREXX question
Just can't stay away
Joined:
2006/12/1 18:01
From Copenhagen, Denmark
Posts: 1048
@Raziel

You probably won't benefit from RxSet then, nor probably using SetEnv or similar, because I assume you will be dealing with multiline data (such as HTTP headers). RxSet and SetEnv will only save the first line of the input.

If so, my best advice would be to simply redirect the output of curl into a file in RAM: and then read that file from ARexx and close and delete it afterwards. I think one or some of the third-party support libraries (rexxtricks? RMH? rexxarplib?) have a function to read a complete file into a stem variable, one line per stem, which might make this option a bit more neat for you. But I can't ATM see a way around a file.

BTW, you may already know this, but if you want to make sure you can run multiple copies of your script simultaneously, make the result of a PRAGMA('I') part of your temporary filename - this will make it unique.

Best regards,

Niels

   Report Go to top

Re: AREXX question
Home away from home
Joined:
2006/11/26 21:45
From A haunted Castle somewhere in the Bavarian Mountains
Posts: 2986
@nbache

Thank you.

I never used the PRAGMA var, but will try to next time.

I'm going to write it with file I/O then.
Lets see how good it behaves while in network startup.

A DOS script isn't behaving really well, two out of three times blocking the boot with need to reboot. Pretty obviously my scripting though

_________________
If slaughterhouses had glass walls, everyone would be a vegetarian. ~ Sir Paul McCartney
-
Did everything just taste purple for a second? ~ Philip J. Fry
-
Ain't got no cash, ain't got no style, ladies vomit when I smile. ~ Dr. John Zoidberg
   Report Go to top

Re: AREXX question
Home away from home
Joined:
2006/11/26 21:45
From A haunted Castle somewhere in the Bavarian Mountains
Posts: 2986
@all

Ok, i need help.

Obviously i'm ding something wrong with the IF THEN ELSE stuff as i'm getting an error:

Quote:

+++ Error 21 in line 64: Unexpected ELSE or OTHERWISE
Command returned 10/21: Unexpected ELSE or OTHERWISE


I already learned that AREXX doesn't feature an ENDIF switch, but it does feature END (only for DO WHILE loops?).

How do i use that properly, so it doesn't always hit me when i use more than one command in an IF loop.

IF B THEN DO
    
ADDRESS COMMAND 
    ADDRESS COMMAND 
    ADDRESS COMMAND 
    ADDRESS COMMAND 
ELSE
    
ADDRESS COMMAND


The above works fine when i leave out the last two lines, as soon as i add ELSE i'm getting the error.

Why?
Unfortunately my manual is falling apart and it doesn't hold very much information regarding loops.

TIA

_________________
If slaughterhouses had glass walls, everyone would be a vegetarian. ~ Sir Paul McCartney
-
Did everything just taste purple for a second? ~ Philip J. Fry
-
Ain't got no cash, ain't got no style, ladies vomit when I smile. ~ Dr. John Zoidberg
   Report Go to top

Re: AREXX question
Just can't stay away
Joined:
2006/12/1 18:01
From Copenhagen, Denmark
Posts: 1048
@Raziel

Your DO needs to be paired with and END before the ELSE.

Since the ELSE branch only contains one statement, it's optional to wrap that in another DO/END pair, but I usually do it myself (just as I also use curly brackets in C/JS etc. even for a one-line branch). It's probably mostly a matter of taste.

But the main thing is: If you have a DO, then you need to end it with an END.

Best regards,

Niels

P.S. BTW, I've used ARexxGuide as a manual for years, it's brillant: http://aminet.net/search.php?query=arexxguide
IIRC, you want the 2.0A stuff.

   Report Go to top

Re: AREXX question
Just can't stay away
Joined:
2006/12/4 23:15
Posts: 1979
@Raziel

/* */

options results

ADDRESS COMMAND 
"version >PIPE:foo"

if open('P',"PIPE:foo",'R'then do
    
line readln('P')
    
say "We Got:" line
    call close
('P')
end


for longer outputs you may wish to 'run' the command to avoid filling the pipe.

or use python and popen()

#!python

import os

os.popen("version")

line f.read()

f.close()

print 
line.strip('\n')


or in your specific usage case dump cUrl and send a request direct using tye TCP: device.

or use httplib module in python.

_________________
Blender For OS4.x : Blues : Walker Broad
   Report Go to top

Re: AREXX question
Just can't stay away
Joined:
2006/11/24 18:52
From Gloucestershire, UK.
Posts: 1135
@Raziel

Grab this:

http://aminet.net/package/docs/help/arexxbegin

Iy'll help with all those little syntax niggles.

_________________
Amiga user since 1985
AOS4, A-EON, IBrowse & Alinea Betatester

Ps. I hate the new amigans website. <shudder>
   Report Go to top

Re: AREXX question
Home away from home
Joined:
2006/11/26 21:45
From A haunted Castle somewhere in the Bavarian Mountains
Posts: 2986
@all

Thanks a lot to all of youi

_________________
If slaughterhouses had glass walls, everyone would be a vegetarian. ~ Sir Paul McCartney
-
Did everything just taste purple for a second? ~ Philip J. Fry
-
Ain't got no cash, ain't got no style, ladies vomit when I smile. ~ Dr. John Zoidberg
   Report Go to top

Re: AREXX question
Just can't stay away
Joined:
2006/12/9 10:44
From Lyon, France
Posts: 1324
@Raziel

The only solution would be not to use curl and get your file directly from Arexx.
You can have an idea of how it works reading the sources of W3S, the Arexx web server.


Edited by Elwood on 2018/1/6 11:56:20
_________________
Philippe 'Elwood' FERRUCCI
Sam460ex 1.10 Ghz
http://elwoodb.free.fr
   Report Go to top





[Advanced Search]


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project