Attract-Mode Support Forum

Attract-Mode Support => Scripting => Topic started by: iOtero on February 11, 2019, 01:11:30 PM

Title: This script not works. (SOLVED).
Post by: iOtero on February 11, 2019, 01:11:30 PM
This script works perfectly in raspbian and in ubuntu, but not in lakka:

Code: [Select]
#!/bin/bash

IFS=';'

cd /storage/.attract/romlists
rm Favorites.txt

touch Favorites.txt
chmod 777 Favorites.txt

ls *.tag > tagfiles
while read filename
do
  while read gamename
  do
    romlist=`echo ${filename} |cut -f1 -d '.'`
    cat "${romlist}.txt"|grep "^${gamename};" >> Favorites.txt
  done < "${filename}"
done < tagfiles

rm tagfiles
cat Favorites.txt |sort -u > tmp_favorites.txt
mv tmp_favorites.txt Favorites.txt

sleep 5

The reading of the data is correct, but the redirection >> does not do anything.

In putty ssh this comand runs:

Code: [Select]
cat "Atari2600.txt" |grep "Centipede (USA)" >> Favorites.txt
but the script does not.

Does anyone know why?
Title: Re: This script not works. (SOLVED)
Post by: iOtero on February 18, 2019, 08:17:00 AM
How strange, nobody has answered me ... 8)

I already do it myself: you had to convert windows files to linux files, to put it in some simple way.  :-[
Title: Re: This script not works.
Post by: keilmillerjr on February 18, 2019, 08:51:49 AM
Issue with line returns?
Title: Re: This script not works.
Post by: iOtero on February 19, 2019, 02:15:20 AM
Issue with line returns?

I do not know exactly, but i think it has to do with the format of the tags, that you have to pass it from dos to linux.
Before executing the script, you must execute:

Code: [Select]
dos2unix *.tag
And then, it works...
Title: Re: This script not works.
Post by: keilmillerjr on February 19, 2019, 04:03:22 AM
It is indeed the line return.

Carriage Return (commodore, early Mac and dos)
Line Feed (Unix)
End Of Line (EOL/CRLF) combines both for best compatibility

Dos2unix tool should make sense now. Parameter you passed will make the tool parse each file in the current path ending with .tag

Try to create new files CRLF. Sometimes I make this simple mistake, using if I’m starting using some one else’s file as a base.

Edit: try something like this to write to file:
echo -e “line1/r/nline2” >> test.txt
Title: Re: This script not works.
Post by: iOtero on February 19, 2019, 09:11:18 AM
You know what i think, Keil: If something works, do not touch it.  8)

And my script, now works fine...   ;D