|
Stack Overflow recommended to get a better answer than "object", I should try `Object.prototype.toString.call(thing)`. Reading stack overflow was probably the big mistake here.
|
![]() |
|
![]()
|
# ? Sep 27, 2023 14:54 |
|
What are you trying to do?
mystes fucked around with this message at 14:54 on Jun 2, 2023 |
![]() |
|
I was trying to figure out what the type of this unknown return value is so I can use it in my code.
|
![]() |
|
if you're trying to print it for debugging wouldn't you want stringify not parse?
|
![]() |
|
it looks like it's an array, op
|
![]() |
|
Jabor posted:it looks like it's an array, op
|
![]() |
|
mystes posted:if you're trying to print it for debugging wouldn't you want stringify not parse? yeah you want JSON.stringify(thing) assuming thing is an array, thing.prototype.toString will just output every item as a comma separated string
|
![]() |
|
expect is good, don't understand why you would be using it in anger
12 rats tied together fucked around with this message at 17:37 on Jun 2, 2023 |
![]() |
|
Why wouldn’t you use python and Paramiko for ssh access? Then smash things into the shell?
|
![]() |
|
expect is purpose built for this sort of thing so the code ends up being smaller and you write less of it which means there's less chance you screw up your parser and run a bunch of poo poo in the wrong context it's also like decades old so the documentation is good and you can just learn it once and never have to update your understanding. anyway most of the time i write expect i use pexpect
|
![]() |
|
distortion park posted:How much data is there? Do you have an intern handy? It's not a one-off thing, we want to build a cronjob that goes and grabs the up-to-date data as often as possible 12 rats tied together posted:expect is purpose built for this sort of thing so the code ends up being smaller and you write less of it which means there's less chance you screw up your parser and run a bunch of poo poo in the wrong context Thanks, I hadn't found pexpect yet and it might be helpful The issue I'm currently having is that I'm not sure if the ASCII GUI I get from the mainframe is even supposed to work with expect. Like I can log through the SSH via expect just fine, but after that I need to press enter a couple of times to reach the right menu, and having "send '\r'" (with sleeps and --slow) in my script does nothing, at least nothing that shows up in the asciinema recording (it's not an issue with asciinema because it works when doing it manually w/o expect).
|
![]() |
|
NihilCredo posted:terrible programmer stories: we need to get some data off an ancient terminal ui (think curses) for a mainframe that is only accessible via SSH, because getting direct database access is apparently politically impossible, and the web api has only half the data we need I think I used expect(1) to automate device testing over serial and it’s real fun to use but that must have been like 20 years ago or so
|
![]() |
|
NihilCredo posted:It's not a one-off thing, we want to build a cronjob that goes and grabs the up-to-date data as often as possible maybe force a tty with ssh -t host or '\r\n' instead of '\r'
|
![]() |
|
in normal expect iirc you expect the prompt you're looking for and include expect_continue which turns it into a little poller by resetting the timeout and then expecting again pexpect otoh kinda sucks because you expect with a timeout and it raises an exception that you have to catch, but you can catch it and retry either way it's not too bad to implement "keep sending enter until you get a prompt, and then ...". you gotta find out what character enter is sending though.
|
![]() |
|
RokosCockatrice posted:I was trying to figure out what the type of this unknown return value is so I can use it in my code. Please post the actual inputs you typed and the console outputs you were given. The examples you gave were ambiguous to a point which makes it impossible for thing to be anything really. For example, it's impossible for Object.prototype.toString.call(thing) to return "string". I'm guessing that what you meant is that it actually returned "[object String]", which means thing is definitely a string, and definitely not an array. Yet elsewhere you're calling thing.map with no problems and thing instanceof Array is returning true, which means thing is definitely an array and definitely not a string.
|
![]() |
|
NihilCredo posted:terrible programmer stories: we need to get some data off an ancient terminal ui (think curses) for a mainframe that is only accessible via SSH, because getting direct database access is apparently politically impossible, and the web api has only half the data we need I've used expect before, and also pexpect (expect, but Python). It's reasonably needs-suiting. Works best if you're an old though. Why do you need asciinema? Can you launch ssh in a subprocess and just capture the stdout? Poopernickel fucked around with this message at 23:51 on Jun 2, 2023 |
![]() |
|
NihilCredo posted:terrible programmer stories: we need to get some data off an ancient terminal ui (think curses) for a mainframe that is only accessible via SSH, because getting direct database access is apparently politically impossible, and the web api has only half the data we need how much data? I've banged out something like this (extracting inventory data from an as400 via an insanely jank terminal emulator) with autohotkey navigating, copying, and pasting data into a spreadsheet but obviously that would take ages if it was more than ~thousands of records.
|
![]() |
|
tef posted:drove my coworker mad that i was using vim over ssh on a machine 5000mi away, couldn't understand how i dealt with the lag vi was designed to make you feel productive despite lag
|
![]() |
|
Nothing.makes you productive with lag like an editor where you constantly belatedly realize you were in the wrong mode and not actually entering the text you thought you were
|
![]() |
|
this is why you use something like emacs’ tramp. run the editor locally, only notice latency when actually doing io
|
![]() |
|
Vscode has something like that too
|
![]() |
|
you wouldn't have that problem if you didn't use a modal editor
|
![]() |
|
actually vi is good
|
![]() |
|
yeah, final fantasy vi
|
![]() |
|
Can your text editor suplex a train?
|
![]() |
|
ikanreed posted:Can your text editor suplex a train?
|
![]() |
|
Modal editing is really not that complicated, I had the basics pretty much down in like, a week or two
|
![]() |
|
InternetOfTwinks posted:Modal editing is really not that complicated, I had the basics pretty much down in like, a week or two
|
![]() |
|
Modal editing is great. You just have to stick with it for long enough for the Stockholm syndrome to kick in
|
![]() |
|
i type seconds ahead of vim updating pretty regularly and it’s completely fine 99% of the time but sometimes you discover that the entire file is now lowercase and have to back up a few steps
|
![]() |
|
After a few months of using it: MISRA is cool and good. except for the rule that only allows one return in a method. It leads to a lot of nested if statements.
|
![]() |
|
FlapYoJacks posted:After a few months of using it: MISRA is cool and good. except for the rule that only allows one return in a method. It leads to a lot of nested if statements.
|
![]() |
|
how is anyone typing ahead of their editor in tyool 2023? just ask your work for a better computer
|
![]() |
|
mystes posted:I hear that's hard to treat good luck sounds misrable
|
![]() |
|
qsvui posted:how is anyone typing ahead of their editor in tyool 2023? just ask your work for a better computer Look it, my brother word processor was fine in 1989 and it’s fine now!!!!
|
![]() |
|
qsvui posted:how is anyone typing ahead of their editor in tyool 2023? just ask your work for a better computer
|
![]() |
|
Nano first, then VIM.
|
![]() |
|
i mean i actually use Rider with vim keybinds but w/e
|
![]() |
|
Oh no, you have jetbrain
|
![]() |
|
![]()
|
# ? Sep 27, 2023 14:54 |
|
Jetbrain IDEs are the best IDEs.
|
![]() |