LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-14-2020, 01:23 AM   #1
aristosv
Member
 
Registered: Dec 2014
Posts: 197

Rep: Reputation: 3
typing or pasting Greek characters in a bash script


I am using a bash script to send SMS messages using an SMS gateway. The script is something like this:

Code:
msg="this is a test"

while read phone; do
 echo
 echo working on "$phone"
 curl -s -S -k --data-urlencode "msg=$msg" "$api?username=$username&userid=$userid&handle=$handle&from=$from&to=$prefix$phone"
done < numbers
I want to replace the $msg value with Greek characters, like this:

Code:
msg="αυτή είναι μια δοκιμή"
When I try to type the Greek text in the bash script, I just get spaces or tabs and no characters appear. I can't even copy the Greek text from a notepad in Windows and paste it in the bash script.

I'm guessing it has something to do with encoding, but I couldn't find a way to do this. Any suggestions?
 
Old 02-14-2020, 01:48 AM   #2
berndbausch
Senior Member
 
Registered: Nov 2013
Location: Tokyo
Distribution: A few
Posts: 4,154

Rep: Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169Reputation: 1169
Quote:
Originally Posted by aristosv View Post
When I try to type the Greek text in the bash script, I just get spaces or tabs and no characters appear. I can't even copy the Greek text from a notepad in Windows and paste it in the bash script.

I'm guessing it has something to do with encoding, but I couldn't find a way to do this. Any suggestions?
You are probably right. Check your LANG variable. What is its current value?

Assuming your terminal or terminal emulator is set up for Greek, setting your LANG variable to en_US.utf-8 should work. You can also use el_CY.utf-8 (for Cyprus, if applicable) or el_GR.utf-8 (the motherland ). In all cases, the encoding will be UTF-8, which is likely to be in your interest.

If that is the value of LANG already, I wonder if you are missing fonts, or perhaps the terminal emulator is not configured correctly.
 
Old 02-14-2020, 08:46 AM   #3
bazio101
LQ Newbie
 
Registered: Feb 2020
Location: Greece
Distribution: Slackware
Posts: 11

Rep: Reputation: Disabled
typing or pasting Greek characters in a bash script

My LANG variable is set to en_US.UTF-8.
I see blank characters on xterm but if I use uxterm, greek letters appear just fine.
What terminal emulator you use?
 
Old 02-14-2020, 09:33 AM   #4
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,845

Rep: Reputation: 629Reputation: 629Reputation: 629Reputation: 629Reputation: 629Reputation: 629
Quote:
Originally Posted by bazio101 View Post
My LANG variable is set to en_US.UTF-8.
I see blank characters on xterm but if I use uxterm, greek letters appear just fine.
What terminal emulator you use?
Strange, I am using xterm and it displays fine, no problem with copy/paste. I do not have a greek keyboard layout set and was still able to copy/paste the first line. Language is also en_US.UTF-8.
Code:
$ msg="αυτή είναι μια δοκιμή"
$ echo $msg
αυτή είναι μια δοκιμή
$ echo $LANG
en_US.UTF-8
There seems to be another factor that we are missing.
 
Old 02-14-2020, 09:52 AM   #5
boughtonp
Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 255

Rep: Reputation: 147Reputation: 147
All the replies so far are referring to terminals, but I don't actually see any reference to a terminal being used.

Quote:
Originally Posted by aristosv View Post
When I try to type the Greek text in the bash script, I just get spaces or tabs and no characters appear. I can't even copy the Greek text from a notepad in Windows and paste it in the bash script.
You are not typing/pasting "in the bash script", you are editing the script with a particular editor, and it is the editor you are typing/pasting in. Which editor are you using?

Also, are you using Bash within Windows (If so how: cygwin/msys/wsl/other?), or are you connecting to a remote Linux-based machine, or running it in a VM?

 
Old 02-14-2020, 10:17 AM   #6
bazio101
LQ Newbie
 
Registered: Feb 2020
Location: Greece
Distribution: Slackware
Posts: 11

Rep: Reputation: Disabled
typing or pasting Greek characters in a bash script

Copy / paste don't work on xterm.
Greek letters appear fine on xfce4-terminal too.
Maybe it has to do with xterm configuration.
 
Old 02-14-2020, 04:47 PM   #7
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,643

Rep: Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813Reputation: 1813
Quote:
Originally Posted by bazio101 View Post
Copy / paste don't work on xterm.
Greek letters appear fine on xfce4-terminal too.
Maybe it has to do with xterm configuration.
You can create the following alias for xterm:
Code:
alias xterm="xterm -en el_GR.UTF8"
 
Old 02-15-2020, 04:24 AM   #8
bazio101
LQ Newbie
 
Registered: Feb 2020
Location: Greece
Distribution: Slackware
Posts: 11

Rep: Reputation: Disabled
Thanks for your help.
This "xterm -en el_GR.UTF-8", made me check the actual executing command which had the "-fn 10x20" option (and many others).
After many "add - remove" I realize it's a font problem. By removing the above, it works great.
Never tried to use Greek letters in terminal all these years...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
@FedEx Tracking: pasting correct tracking # causes error; typing same works mike3644 Linux - Software 7 02-15-2018 04:55 PM
Typing out this command works over "pasting" it, could this be an anomaly in xfce4-terminal? d_K Linux - Newbie 4 01-16-2017 06:32 AM
Copying and pasting from web to vim changes some characters to periods szboardstretcher Linux - Software 1 07-03-2013 04:53 PM
GNU virtual keyboard for pasting special characters Mr. Alex Linux - Software 2 01-01-2013 11:05 AM
Typing in Greek in OpenOffice under RH9 evalastin Linux - Newbie 1 12-10-2004 05:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration