![]() |
![]() |
#1 |
Registered User
Join Date: Nov 2022
Location: #Amigaland
Posts: 156
|
How do I get the IP from this output?
I've been trying to find some information on how to "parse" text, I usually manage to figure things out but not this time.
I just want the IP from roadshow, all I've found is ShowNetStatus which outputs this: Network status summary Local host address = 192.168.100.13 (on interface 'Prism2') Default gateway address = 192.168.100.1 Domain name system servers = 192.168.100.1, 192.168.100.1 But how do I script so it just outputs the IP (host address)? Last edited by shelter; 27 January 2023 at 14:14. |
![]() |
![]() |
#2 |
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,456
|
Hi Shelter!
Maybe you could write your own program (in C?) that could output only your IP address or use something like this? Cheers! |
![]() |
![]() |
#3 |
Phone Homer
Join Date: Jun 2006
Location: 5150
Posts: 5,887
|
Is there a way to parse it through 'Type' or something so it outputs the first line only?
|
![]() |
![]() |
#4 |
Paranoid Amigoid
Join Date: Mar 2008
Location: Athens/Greece
Age: 45
Posts: 1,978
![]() |
You can use GetIP (AmiTCP, Miami, RoadShow) or GetIPAddress (For everything + WinUAE) from Flype's GitHub
https://github.com/flype44/AmigaOS ![]() |
![]() |
![]() |
#5 |
Registered User
Join Date: Nov 2022
Location: #Amigaland
Posts: 156
|
Wow. I searched for such a program but I don't find any. Thanks.
I actually thought about writing something myself but I don't know C that well. |
![]() |
![]() |
#6 |
Registered User
Join Date: Oct 2009
Location: Germany
Posts: 3,326
|
Here a ShowNetStatus ARexx script version without error checking just for the record:
Code:
/* Get the IP from ShowNetStatus */ ADDRESS COMMAND 'ShowNetStatus >RAM:tempout' CALL OPEN('tempfile', 'RAM:tempout', 'R') CALL READLN('tempfile') str = READLN('tempfile') /* read the second line */ CALL CLOSE('tempfile') PARSE VAR str . . . . ip . /* get the fifth word */ SAY ip 'delete RAM:tempout' Last edited by daxb; 29 January 2023 at 20:40. |
![]() |
![]() |
#7 |
Paranoid Amigoid
Join Date: Mar 2008
Location: Athens/Greece
Age: 45
Posts: 1,978
![]() |
It needs one more dot on that line:
PARSE VAR str . . . . ip . /* get the fifth word */ cause you get the " = " in output (at least on my 3.2.1 setup). Also deleting the RAM:tempout gives an error that is in use. I even put a delay of 1 sec and still same. if you delete outside the script it works just fine... weird ![]() |
![]() |
![]() |
#8 |
Registered User
Join Date: Oct 2009
Location: Germany
Posts: 3,326
|
Thanks for testing and correction! Such things happen if you don't test it. The missing dot must be ate by Pacman.
![]() |
![]() |
![]() |
#9 |
Paranoid Amigoid
Join Date: Mar 2008
Location: Athens/Greece
Age: 45
Posts: 1,978
![]() |
Yep it should be fine.
I don’t know arexx but learning slowly although I remembered from other languages you need to close the file cause on delete is still open ![]() |
![]() |
![]() |
#10 |
Registered User
Join Date: Sep 2007
Location: Stockholm
Posts: 4,381
|
If you use PIPE: for output and input, you won't have to deal with deletion or closing files.
|
![]() |
![]() |
#11 |
Registered User
Join Date: Nov 2022
Location: #Amigaland
Posts: 156
|
Thanks, here's something simple I wrote for GetIP to put the IP in environment variables.
Code:
set IP `GetIP` ; Outputs IP: <yourip> setenv net_txtip "IP:" `get IP` ; Outputs <yourip> setenv net_ip `get IP` |
![]() |
![]() |
#12 |
Paranoid Amigoid
Join Date: Mar 2008
Location: Athens/Greece
Age: 45
Posts: 1,978
![]() |
I use that for displaying my IP on the titlebar as well
![]() Code:
FailAt 21 C:GetIPAddress >ENV:IP If Warn Echo "" >ENV:IPBar Else Echo "IP: $IP" >ENV:IPBar EndIf This is a script on S: that I execute everytime on Network-Startup and Network-Shutdown script so I always have the correct IP on titlebar |
![]() |
![]() |
#13 | |
Registered User
Join Date: Jun 2020
Location: Germany
Posts: 380
|
Does anyone know an alternative for uae4arm (android)?
I've tried the tools mfilos linked but it seems that uae4arm is too old and therefore doesn't has the required flag. From the GetIPAddress source: Quote:
|
|
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Output to CLI | REAKTOR BEAR | Coders. Asm / Hardware | 8 | 29 September 2022 11:03 |
CRT Tv Output | Leandro Jardim | support.WinUAE | 8 | 24 May 2013 14:54 |
output delay? | jharrison | support.WinUAE | 16 | 01 February 2009 23:16 |
output problem :( | RickyC | support.WinUAE | 8 | 16 July 2008 23:36 |
COMP output | Enverex | support.Hardware | 19 | 16 February 2004 19:53 |
|
|