Edit2: Solved! Thank you all! 🥰 I was supposed to put quotation marks around the command argument variable/substitute within the script, as in scanimage -d [device] –format=png -p -o “$1”

Edit: turns out it's not the accented character, but the whitespace character in front of július.png, since the script doesn't accept julius.png either.

#!/bin/bash  
# name of the script is SCAN.bash  
scanimage -d [device] --format=png -p -o $1  

I have tried ' ', " " and to escape it with \

./SCAN 'anyu 1988 július.png'  
./SCAN "anyu 1988 július.png"  
./SCAN anyu\ 1988\ július.png  

But it throws argument without option. It works fine if I type it out instead of scripting.

The target language is Hungarian and I have generated the necessary locale.

all 8 comments

sorted by: hot top controversial new old
[–] 13 points 6 days ago (1 child)

Put the $1 in quotes in the script. -o "$1" ?

  • source
  • hideshow 1 child comment
  • [–] 7 points 6 days ago (1 child)

    Shellcheck can help spotting such mistakes: https://www.shellcheck.net/

  • source
  • hideshow 1 child comment
  • [–] 5 points 6 days ago* (last edited 6 days ago)

    If there is whitespace in the filename, when you pass it to the script you need to escape it or wrap it in quotes. And then you need to put quotes around the variable in the script that reads the parameters.

    From what you posted, you aren't including the space in the filename inside the quotes

  • source
  • [–] 2 points 6 days ago (1 child)

    ahhh ... found your problem: Put double quotes around the $1 in the bash script: scanimage -d [device] --format=png -p -o "$1"

  • source
  • hideshow 1 child comment
  • [+] 1 point 6 days ago* (last edited 6 days ago)