help for script
-
so for the b ;)
i just wanna replace "#PermitRootLogin prohibit-password" to "PermitRootLogin yes" in only one files "etc/ssh/sshd_config" i don't need a loop my mistakefor the a
the "test.sh" is in the directorythe tuto
http : //www.tux-planet . fr/remplacer-un-chaine-de-caractere-avec-la-commande-sed/ps delete the space to / and . in the url I cant' post the link
-
Try
type ./test.sh
. If this also doesnt work, your filename may contain invisible characters that nevertheless count as part of the filename (creating the file in Windows may do that). See here for a more thorough explanation and solution approach.If, however,
type
does work, trysudo bash ./test.sh
to execute the script in a new bash instance. Depending on your system's setup,sudo
may not like to execute scripts directly. -
ok sudo bash ./test.sh launch the script ( the probleme a it's solved ;) ) but it's not work ( the problem b still here ;) )
-
If it's still the same as in your post above, it can't work unless you fill the variables with content. 🧐
-
hello sorry for long silent, i've try many thing today
if i've type
sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
it's work but if I make this in a script, it's don't work
#!/bin/bash sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config echo "root activate"
i' ve this message
pi@retropie:~ $ sudo bash ./root.sh ./root.sh: line 2: $'\r': command not found : No such file or directoryhd_config ./root.sh: line 4: $'\r': command not found
someone have an idea ?
-
@wsamael said in help for script:
i' ve this message
Your script has Windows (DOS) line endings, make sure you edit the script with an editor that understands Unix line endings and set your editor to save your script correctly. When in doubt, use Notepad++.
-
Or you could do it in Retropie's command line:
sed -i 's/\r$//' root.sh
or
sudo apt install dos2unix # only needed once to install dos2unix dos2unix root.sh
Both edit the file in place, so be sure to have a backup if anything goes wrong.
Source: https://askubuntu.com/questions/803162/how-to-change-windows-line-ending-to-unix-version
-
@mitu usually I use sublim text but not this time my mistake
-
@Clyde the first solution it's for convert my script to unix script ? Good to know. I'll try this, but for my next script i would like to make them in unix language ;)
-
@wsamael said in help for script:
@Clyde the first solution it's for convert my script to unix script ?
Both are. The first doesn't require the installation of another tool, as
sed
is party of most Linux base installations; the second may be more easy to remember as something like's/\r$//'
. ;) -
I try
sed -i 's/\r$//' root.sh
it's work but I see no difference beetwen my script, how did you see what 's wrong with my script ? (i would be understand ^^ )
-
@wsamael Your error message said:
'\r': command not found
Windows ends a line in a text file with a carriage return (
\r
) and a line feed (\n
), wheras unixoid systems only use\n
. Thus Retropie's command shellbash
rejected the\r
in your file as an unknown command. -
ok i understand thank you ;)
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.