Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
107 user(s) are online (64 user(s) are browsing Forums)

Members: 1
Guests: 106

sailor, more...

Headlines

 
  Register To Post  

AREXX question
Home away from home
Home away from home


See User information
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

People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Go to top
Re: AREXX question
Not too shy to talk
Not too shy to talk


See User information
@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">"



Go to top
Re: AREXX question
Home away from home
Home away from home


See User information
@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.

People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Go to top
Re: AREXX question
Just can't stay away
Just can't stay away


See User information
@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

Go to top
Re: AREXX question
Quite a regular
Quite a regular


See User information
@Raziel

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

Go to top
Re: AREXX question
Home away from home
Home away from home


See User information
@Amigo1

Of course, all hints welcome

@nbache

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

Thanks to both of you

People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Go to top
Re: AREXX question
Just can't stay away
Just can't stay away


See User information
@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

Go to top
Re: AREXX question
Home away from home
Home away from home


See User information
@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.

People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Go to top
Re: AREXX question
Just can't stay away
Just can't stay away


See User information
@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

Go to top
Re: AREXX question
Home away from home
Home away from home


See User information
@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

People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Go to top
Re: AREXX question
Home away from home
Home away from home


See User information
@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

People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Go to top
Re: AREXX question
Just can't stay away
Just can't stay away


See User information
@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.

Go to top
Re: AREXX question
Home away from home
Home away from home


See User information
@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.

Go to top
Re: AREXX question
Just can't stay away
Just can't stay away


See User information
@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>
Go to top
Re: AREXX question
Home away from home
Home away from home


See User information
@all

Thanks a lot to all of youi

People are dying.
Entire ecosystems are collapsing.
We are in the beginning of a mass extinction.
And all you can talk about is money and fairytales of eternal economic growth.
How dare you!
– Greta Thunberg
Go to top
Re: AREXX question
Just can't stay away
Just can't stay away


See User information
@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
Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project