0

I using the following python script to create a shell script:

with open("decode_JOURNAL2017.sh", "a") as myfile:
    levels_no = 16
    #myfile.write("#!/bin/bash\n")
    for x in range(0, levels_no):
        myfile.write("/home/zinonas/SHM-12.3/bin/TAppDecoderStatic -b /home/zinonas/str/pirkagia_10b_lowdelay_P.bin -olsidx "+str(x)+" -o"+str(x)+" /home/zinonas/decode/pirkagia_10b_lowdelay_P_level_"+str(x)+"_dec.yuv >> /home/zinonas/decode/pirkagia_10b_lowdelay_P_level_"+str(x)+"_dec.txt\n")

Then I transfer the following created script to an ubuntu server:

/home/zinonas/SHM-12.3/bin/TAppDecoderStatic -b /home/zinonas/str/pirkagia_10b_lowdelay_P.bin -olsidx 0 -o0 /home/zinonas/decode/pirkagia_10b_lowdelay_P_level_0_dec.yuv >> /home/zinonas/decode/pirkagia_10b_lowdelay_P_level_0_dec.txt
/home/zinonas/SHM-12.3/bin/TAppDecoderStatic -b /home/zinonas/str/pirkagia_10b_lowdelay_P.bin -olsidx 1 -o1 /home/zinonas/decode/pirkagia_10b_lowdelay_P_level_1_dec.yuv >> /home/zinonas/decode/pirkagia_10b_lowdelay_P_level_1_dec.txt
/home/zinonas/SHM-12.3/bin/TAppDecoderStatic -b /home/zinonas/str/pirkagia_10b_lowdelay_P.bin -olsidx 2 -o2 /home/zinonas/decode/pirkagia_10b_lowdelay_P_level_2_dec.yuv >> /home/zinonas/decode/pirkagia_10b_lowdelay_P_level_2_dec.txt

When I run it, the txt files are created but when I double click to one to open it I get this message:

Can't create file 'C:\Users\admin\AppData\Local\Temp\scp43940\home\zinonas\decode\pirkagia_10b_lowdelay_P_level_0_dec.txt
'.
System Error.  Code: 123.
The filename, directory name, or volume label syntax is incorrect

I can't even transfer this txt file to my windows desktop via winscp.

The yuv files are working properly!

EDIT: When I copy/paste the content of the shell script to the terminal, the txt files are working properly. EDIT 2: When I rename the file and remove txt and add it again, the file opens properly...

Do you know how to fix this?

Thank you in advance!

zinon
  • 4,427
  • 14
  • 70
  • 112
  • @molbdnilo When I try to open other txt files from the server, `winscp` opens them correctly. I believe that the error might be in the `shell` script. – zinon Aug 09 '17 at 09:04

3 Answers3

1

You probably have Windows line endings in the script file – at least that's why I get from the error message if you pasted it correctly.

Run dos2unix scriptFilename.sh or sed -i 's/\r//' scriptFilename.sh to remove the Windows line endings from the script.


For Python scripting refer to this Question&Answer: How to write Unix end of line characters in Windows using Python

rehael
  • 36
  • 1
  • 4
0

I found the solution.

While creating the shell script, next to the name of the txt file I had:

...
>> /home/zinonas/decode/pirkagia_10b_lowdelay_P_level_"+str(x)+"_dec.txt\n")

so the new line character \n want next to txt. That was the problem. I added a new space between them and the problem solved!

My new code now reads:

...
>> /home/zinonas/decode/pirkagia_10b_lowdelay_P_level_"+str(x)+"_dec.txt \n")
zinon
  • 4,427
  • 14
  • 70
  • 112
0

Is there a "rogue" CR at the end of the file name?