-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Iterate over string in shell script? #1974
Comments
We're running a pretty early version of bash because of size constraints, some of the string variables operations are implemented, but I can't remember which ones. Can you give an example of some working Linux bash shell programming that you'd like to duplicate? We will likely have to look at the source to determine what /bin/sh can and can't do, it lives in elkscmd/ash/var.c and elkscmd/ash/bltin/expr.c. There are other ways to read the serial port if you want to run or write a program, see |
I'd like to get the length of a string and then iterate over it, like this: foo=string for (( i=0; i<${#foo}; i++ )); do Thanks |
Dang, our bash doesn't support numeric variables such as in your for loop, nor substrings using ${var:start:len}. I have a slightly newer version of bash (actually ash) from 1993 instead of our 1991 version I'm looking at, which I have previously considered porting of its parameter expansion over. That version adds support for So unfortunately - there isn't a way to do what you want in the shell at this time. |
How do I use sercat to receive a file over serial? I tried this on ELKS:
Then on the other Linux computer:
The file /root/test.txt wasn't even created and the echo failed to close sercat. Please let me know how it's supposed to flow. Thanks |
Sercat sets the serial line in raw mode so sending a ^D won't close the file. The easiest way to make it work is to cat the file over from the remote system to ELKS, then interrupt sercat on ELKS with ^C after the data has been sent, which it catches, which then writes the file. The likely reason you never saw /root/test.txt created is because ELKS was rebooted without running "sync". The file was created but not synced to disk. This can be made automatic by uncommenting |
^C and ^D both failed to close sercat given the above command. I had to reboot. Does it work for you? Thanks |
Also, what is the command to change the baud rate of /dev/ttyS0 in ELKS? Thanks |
Well - no! Geez, nothing but bugs around here. For some reason (which I'm looking into and will fix) the ^C interrupt from the ELKS console doesn't actually interrupt the
|
Hello @RNRetailer,
I have found and fixed this problem in #2001, if you're still interested in trying it out. Are you compiling the system yourself or running from compiled binaries? The It seems that Picocom isn't necessarily a quick-and-dirty port over to ELKS. What kinds of files are you trying to transfer into ELKS? I'm sorry to see all these troubles. Perhaps I can help make sercat work for you if this fix doesn't do that. Thank you! |
I'm using the precompiled ELKS v0.7.0 If you make a new release I can test out your new I was just transferring simple text files to see if I could edit them locally on my 286. From my testing the included Thanks |
We're not quite ready to cut a new release yet, although one is overdue. I've attached a 1440k (MINIX) image for you to test, with sercat in /root's directory. It requires this updated kernel in order to work. Let me know how it goes.
What exactly? I have no known bugs with vi, but you're doing pretty good finding them! |
That floppy image didn't work for me. It booted to this message:
I'm using a Compaq Portable III with 286 + 287 and 640 KB ram. The floppy is a standard 3.5" 1.44 MB. Thanks |
I just tried the image again and it is working.
The * means disk sector read retry and the 1 means disk read error. I would guess your floppy is bad? |
Hi,
How do I iterate over a string in an ELKS shell script?
I found numerous ways that worked in Linux bash but none in ELKS.
I can receive text one line at a time over the serial port but I can't iterate over the characters.
Thanks
The text was updated successfully, but these errors were encountered: