I have been in tech since MS-DOS 1.0, so it's not that i don't understand Windows to a degree, but *NIX is just so much better. I just wanted to create a simple bash shell script and run it. I have GitBash, I have Windows subsystem for LINUX, but this is why I am whining chmod doesn't do anything to a windows file. chmod 700 script.sh doesn't change permissions. Sudo appears in WSL linux but won't accept the password I chose for my account, su doesn't work either. When you turn on a hypervisor and install WSL (windows subsystem for linux) it asks you for a password, but it doesn't work with su or sudo. I could be mistaken but i completely reinstalled WSL on another computer and it is the same.
Maybe someone who knows powershell scripting can help. All I want to do is to have a small keepalive script that keeps a WiFi router alive. This is how you would do it it bash:
while true
do
/c/Windows/system32/ping google.com
/c/Windows/system32/ping yahoo.com
sleep 90
done
in this case the paths are from GitBash
I have a feeling this might work better from cygwyn. The formatting for the script looked a lot prettier in the edit window, but since it is so simple it should be easy to see what I'm trying to do. I put "" so you can see where the line returns should be.
CodePudding user response:
You don't need to use powershell or the linux subsystem for that. Age old batch files are still a thing and work with similar syntax.
Create a new file called keepalive.bat somewhere containing following code:
:START
ping google.com
ping live.com
timeout /t 30 /nobreak > NUL
GOTO:START
You can either manually start this by double-clicking the .bat file or you can schedule a task to do it for you when the system boots.
CodePudding user response:
If you have enabled wsl, have your just tried to execute your script with:
bash script.sh
(it works in CMD for me)