1

I need a bash string, which writes to my.sh this code:

#!/bin/sh
uci -q batch <<-EOF > /dev/null
    set wireless.@wifi-iface[0].ssid='WVADSUP'
    set wireless.@wifi-device[0].disabled=0
    commit wireless
EOF
exit 0

I try echo "#!/bin/sh" >> wifi_on , but it doesn`t work.

Chifty
  • 21
  • 6
  • 1
    `but it doesn't work` - what does it mean? How does it "not work"? How do you detect "not working"? Are you interested in how to write `#!/bin/sh` into a file named `wifi_on`, or do you want to write it all? Because you can for example `cat >wifi_on <<'EOF2'` + copy the whole script + type `EOF2`. – KamilCuk Jan 23 '20 at 21:27
  • @tevemadar YES! thats it! – Chifty Jan 23 '20 at 21:34

2 Answers2

1
echo '#!/bin/bash' >> wifi_on

That`s it

Chifty
  • 21
  • 6
0

You can't (easily) prepend to a file, but you can edit the file.

ed wifi_on <<'SCRIPT'
1i
#!/bin/sh
uci -q batch <<-EOF > /dev/null
    set wireless.@wifi-iface[0].ssid='WVADSUP'
    set wireless.@wifi-device[0].disabled=0
    commit wireless
EOF
exit 0
.
wq
SCRIPT
chepner
  • 497,756
  • 71
  • 530
  • 681