Author Topic: This script not works. (SOLVED).  (Read 418 times)

iOtero

  • Sr. Member
  • ****
  • Posts: 298
    • View Profile
This script not works. (SOLVED).
« 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?
« Last Edit: February 19, 2019, 09:11:44 AM by iOtero »
I love that on my laptop the eyes shine to the Alien every time i access the ssd... :D

iOtero

  • Sr. Member
  • ****
  • Posts: 298
    • View Profile
Re: This script not works. (SOLVED)
« Reply #1 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.  :-[
I love that on my laptop the eyes shine to the Alien every time i access the ssd... :D

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 864
    • View Profile
Re: This script not works.
« Reply #2 on: February 18, 2019, 08:51:49 AM »
Issue with line returns?

iOtero

  • Sr. Member
  • ****
  • Posts: 298
    • View Profile
Re: This script not works.
« Reply #3 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...
« Last Edit: February 19, 2019, 02:17:20 AM by iOtero »
I love that on my laptop the eyes shine to the Alien every time i access the ssd... :D

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 864
    • View Profile
Re: This script not works.
« Reply #4 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
« Last Edit: February 19, 2019, 04:16:56 AM by keilmillerjr »

iOtero

  • Sr. Member
  • ****
  • Posts: 298
    • View Profile
Re: This script not works.
« Reply #5 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
« Last Edit: February 19, 2019, 09:19:21 AM by iOtero »
I love that on my laptop the eyes shine to the Alien every time i access the ssd... :D