Reading user input...problem with tab key


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Reading user input...problem with tab key
# 1  
Old 12-26-2013
Linux Reading user input...problem with tab key

Hi all,

I have a little problem with my shell script (reading user input, save user input to variable, invisible characters in the log file Smilie)

Code:
 printf "1. What's your file path?"
 /path/to/my/file
 read -e FILE

I have invisible characters in my log file (e.g. <ESC>[?1034h or ^G) when I'm using the tab key for autocomplete path feature.

Any idea how I can solve this? Thanks in advance.

Last edited by splendid; 12-26-2013 at 01:07 PM.. Reason: Add CODE tags.
# 2  
Old 12-26-2013
You are talking about a log file, but you haven't said anything about what is writing data into that log file. The <ESC>[?1034h looks like an escape sequence used to set terminal display characteristics for many terminals (see ANSI Escape Code). The ^G could either be a visual representation of the <BEL> character (typed by hitting the <Ctl> and G characters simultaneously) or those two characters separately (depending on context and what you are using to view your log file).

There is nothing in the printf command that you've shown us that will write an escape sequence or a <BEL> character. It isn't clear from your post whether /path/to/my/file is data typed by the user in response to the prompt printed by printf or the path to another program to executed. If it is a program that you're executing, look at that file to see if it contains commands that generate those characters.
# 3  
Old 12-26-2013
Everything from the screen is written to my log file.

The tab key in the user input produces the invisible characters!

When I'm typing the full path (without using tab) everything is alright.

---------- Post updated at 06:44 PM ---------- Previous update was at 06:36 PM ----------

Code:
 {
 printf "1. What's your file path?"
 /path/to/my/file
 read -e FILE
  
 cp logfile.txt "$OUTPUT"
  
 } 2>&1 | tee logfile.txt
  
 rm logfile.txt

---------- Post updated at 06:49 PM ---------- Previous update was at 06:44 PM ----------

/path/to/my/file is data typed by the user in response to the prompt printed by printf
# 4  
Old 12-26-2013
I don't recognize <ESC>[?1034h, but it appears to be a DEC private sequence used for certain terminals. It is probably being used by your shell to reposition the cursor as it performs filename completion. Depending on how your terminal is set, the <BEL> should either cause your terminal to flash, make a noise, or both.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to embed data instead of reading user input from an array?

Hello, I am running under ubuntu1 14.04 and I have a script which is sending given process names to vanish so that I'd see less output when I run most popular tools like top etc in terminal window. In usual method it works. Whenever I restart the system, I have to enter the same data from... (2 Replies)
Discussion started by: baris35
2 Replies

2. UNIX for Advanced & Expert Users

Ssh public/private key user login problem

I have a user account configuration with ssh public/private key that works on multiple servers centos and rhel. One server (Server F) that is not working in centos 6.8. When i ssh into server f I get prompted for a password. I have verified the config and it all is good. I put sshd into debug... (8 Replies)
Discussion started by: bash_in_my_head
8 Replies

3. UNIX for Dummies Questions & Answers

User input while reading from a file

I am not able to capture the user input in this script(bash).There is prompt for user input.Could some one help me capture user input while reading afile? while read line do echo "$i" path1=$line path2=`echo $line|sed s/new_dir/old_dir/` echo "Do you want to replace?";... (4 Replies)
Discussion started by: parijat guh
4 Replies

4. Shell Programming and Scripting

Problem in reading the input value

echo "Enter the Value : " read value sed '1s:\(.\{6\}\)\(.\{4\}\):\1'$value':' flextran$RUN_DATE-completed.txt > temp.txt mv temp.txt flextran$RUN_DATE-completed.txt on the run time after entering the input value it waits for keystroke and the values is not input to the function The output... (4 Replies)
Discussion started by: rammm
4 Replies

5. Shell Programming and Scripting

reading yum user input

I am writing a script where it uses yum to install. I need to read the user input for yum ie "y or n". If the user types "y", the script should continue running. If the user types "n" then the whole script should be terminated. line1 line2 yum install package line3 line4 From above,... (5 Replies)
Discussion started by: anilcliff
5 Replies

6. Shell Programming and Scripting

[SH] Problem reading input in script

Alright, so the goal of my script is to read text from standard input and store it into a file using the ex-editor: so far i've got this, but it doesn't work. #!/bin/s read text ex $1 >> HERE text HERE I don't get any errors either, so i don't know what i'm doing wrong. (7 Replies)
Discussion started by: Bertieboy7
7 Replies

7. Shell Programming and Scripting

Problem while taking input from User

Hi All, I am facing a problem while taking input from user in Shell Script. Basically , I want to read a file line by line. And I want to remove certain lines of that file.But before removing those lines , I need to ask the user whether user wants to remove the lines. If user inputs "Yes" , the... (3 Replies)
Discussion started by: swapnil.nawale
3 Replies

8. UNIX for Dummies Questions & Answers

Intermittent problem reading from an input file.

First of all thanks to all for the good post, and the great site. I'm a noob, but I've been able to learna a lot by checking past posts. I haven't been able to make sense of a problem that I've been working on for a while, hopefully someone can help me out. The script I wrote telnets into... (7 Replies)
Discussion started by: Wallygooo32
7 Replies

9. Shell Programming and Scripting

BASH: Any Way to Get User Input Without Requiring Them to Hit the Enter Key?

I'm working on making a menu system on an HP-UX box with Bash on it. The old menu system presents the users with a standard text menu with numbers to make selections. I'm re-working the system and I would like to provide something more akin to iterative search in Emacs. I have a list of 28... (2 Replies)
Discussion started by: deckard
2 Replies

10. Shell Programming and Scripting

Reading input from user

how do we read input from a user e.g i want to ask a user to enter 6 sets of numbers how do i control information from the user? i have this....... #!/bin/bash echo "Please enter six numbers" read number echo $number >> file1 but this stops after the first number..how can i... (2 Replies)
Discussion started by: vadharah
2 Replies
Login or Register to Ask a Question