Skip to content
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

Carriage returns in .sh files when unzipped on Windows machines #35

Open
beneix opened this issue May 9, 2021 · 4 comments
Open

Carriage returns in .sh files when unzipped on Windows machines #35

beneix opened this issue May 9, 2021 · 4 comments

Comments

@beneix
Copy link

beneix commented May 9, 2021

I was unable to get the install to work on my DD-WRT router. Trying to execute the setup script just rendered "not found". Eventually, I figured out (by looking at the file through vi) that there were extraneous carriage returns ("^M") at the end of every line. I removed these using sed -i 's/\r//g' *.sh and everything worked fine after this. I assume the carriage returns had been generated when I unzipped the file on my Windows machine, before using PSCP to transfer it to the router.

Unless my setup somehow is weird, perhaps it would be worth including something about this in the installation instructions?

@pkerney
Copy link

pkerney commented Oct 15, 2021

Not just Windows. I thought that too so I redid it all on Ubuntu Linux. The files in the manual install are ALL windows format. I installed tofrolinux and ran them all through fromdos.
I couldn't get the latest installer script to work at all. All the downloads have redirect HTML in them so had to go to manual mode.

@electricmessiah
Copy link

I ran into the same issues, and copied the manual install files. I can't get the setup4.0.7.sh to work either on OpenWRT. It returns a bunch of errors. Any tips?

@pkerney
Copy link

pkerney commented Feb 7, 2022

Wasn't working so I had another crack at it a few days ago.
I downloaded the manual install zip, unzipped on the router, wrote a script in the router to put all the files through a ^M removal process (below, 'tr' command stolen from a website, or use the 'sed' command above from beneix) and then ran the setup4.0.7.sh.
Some files were Unix format, some were Windows format, so I just did them all anyway.
I had to install into /tmp/mnt/sda1/YAMon4 (due to automount requirements) and made sure "/tmp/mnt/sda1/YAMon4/start.sh 'reboot'" was added to Administration->Commands->Startup in DD-WRT.
It's running now, but I haven't rebooted the router yet. Should be OK.

#!/bin/bash
for f in $( find YAMon4 -type f ); do
        echo $f
        tr -d '\15\32' < $f > unixfile.txt
        rm -f $f
        mv unixfile.txt $f
done

@AmateurCoder105
Copy link

AmateurCoder105 commented Dec 24, 2022

Whenever you extract a zip archive containing UNIX formatted text files onto a Windows system, Windows inserts carriage returns into them, effectively corrupting the scripts. I was able to fix this problem using the dos2unix utility which is available on sourceforge (https://sourceforge.net/projects/dos2unix/). I downloaded and extracted the zip archive on my laptop -- I had to use this method because wget wasn't working for me. You run this on Windows (it also supports MAC) and you want to run it to recursively convert all text files. Then I used winscp to copy the entire file structure to the USB drive while it was connected to my router. Afterwards, I was able to run the setup program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants