Visit Our UNIX and Linux User Community


Bash overwrites data on screen!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash overwrites data on screen!!
# 1  
Old 03-11-2002
Network Bash overwrites data on screen!!

hi everybody,
when i run and compile this:

printf("test"); fflush(stdout);

nothing appears on screen.
if i try this:
___________________________________

printf("test"); fflush(stdout); sleep(10);

___________________________________
then i can see the output "test"... for 10 secondes, and after that the new line of shell overwrites the line of data.
this is:
___________________________________

#./myprog
test
___________________________________
for 10 secondes and then:

___________________________________
#./myprog
#
____________________________________
ive been told that this was beacause the shell overwrites the data.
does anybody knows how to prevent my bash to overwrite my progs?!!!
thanks.
# 2  
Old 03-11-2002
Would adding a \n for newline work for you? Check the format man page (Section 5) which was referenced in the printf man page.
thehoghunter
# 3  
Old 03-11-2002
yes, that's right, if i just write:

printf("test\n");

then it appears properly on screen.
but what if i don't want to use \n ?
and also, the new bash line should appear _next to_ my data, but should not
overwrite it! i would like to know why...
# 4  
Old 03-13-2002
Because that is the default - I found the following at
http://www.gnu.org/manual/bash-2.02/...o/bashref.html

PS1 The primary prompt string. The default value is `\s-\v\$ '.
thehoghunter
# 5  
Old 03-13-2002
thank you very much for answering and helping me!




that's right, the problem comes from the variable PS1.




in fact when i use the csh shell instead of bash my problem disappears.




but i want to keep my bash!




so i have to modify PS1.




my default PS1 is:




[\u@\h \W]\$




this one or the other default keeps the problem.




i read the "man bash" about PS1 and the only solution i saw is to put the option \n

in PS1, this is the new line special character. it solves my problem: i can see my datas.




but: now each time i press return i see a blank line!!




this is not really annoying, but i still don't know exactly which variable or stuff causes the problem.




because now i see:




____________________




[localhost]$./myprog




test




[localhost]$




____________________









and i should see:




____________________




[localhost]$./myprog




test[localhost]$




____________________









this last result is what i obtain with csh for instance.




see you







Smilie

Previous Thread | Next Thread
Test Your Knowledge in Computers #658
Difficulty: Medium
The FreeDOS project began on 26 June 1994, when Microsoft announced it would no longer sell or support MS-DOS.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Help with bash escaping while using screen command

Hello, everyone. I'm currently trying to write a command system for a Minecraft server using screen. Here are the scripts I'm currently using. 0.sh #!/bin/bash screen -S Test114 -dm java -Xmx4G -jar server.jar nogui 1.sh #!/bin/bash args="$@" args2="${args@Q}" #args3=`printf '%q\n'... (2 Replies)
Discussion started by: Develon
2 Replies

2. Shell Programming and Scripting

Parsing XML (and insert data) then output data (bash / Solaris)

Hi folks I have a script I wrote that basically parses a bunch of config and xml files works out were to add in the new content then spits out the data into a new file. It all works - apart from the xml and config file format in the new file with XML files the original XML (that ends up in... (2 Replies)
Discussion started by: dfinch
2 Replies

3. Shell Programming and Scripting

Converting variable space width data into CSV data in bash

Hi All, I was wondering how I can convert each line in an input file where fields are separated by variable width spaces into a CSV file. Below is the scenario what I am looking for. My Input data in inputfile.txt 19 15657 15685 Sr2dReader 107.88 105.51... (4 Replies)
Discussion started by: vharsha
4 Replies

4. Shell Programming and Scripting

Bash: capturing *Anything* which showed on screen

Hi, I have a simple question about I/O redirection. the question is: "How can I redirect all characters from a Bash screen to a file?" Let me describe a little more: I know about I/O Redirection in Bash. and also about stdin/stdout/stderr. something like: # ls 2>&1 1>ls.out But!... (11 Replies)
Discussion started by: siavash
11 Replies

5. Windows & DOS: Issues & Discussions

gVim on windows 7 64 constantly overwrites symbolic and even hard links

I use sugarsync to sync my vimrc across computers. I keep the _vimrc file in a syncing folder and in my home folder, I have a symbolic link ~\_vimrc pointing to ~\Synced Docs\_vimrc. On my mac I have a .vimrc symbolic link pointing at the _vimrc file. On the pc side, every time I open the _vimrc... (3 Replies)
Discussion started by: dp88
3 Replies

6. Shell Programming and Scripting

Redirect overwrites itself

I bet many people faced this problem before: The command below will result in a blank file: $ cat myfile | grep pattern > myfile Is there any easy way to do it? (8 Replies)
Discussion started by: rlopes
8 Replies

7. Shell Programming and Scripting

Clear Screen Command for BASH shell

I am unable to use clear or cls command on bash shell. I have recently installed Cygwin and am using that for practicing unix commands. I see that I can use Ctrl + L to clear the screen. I created an alias in my .bashrc to do the same as alias cls='^L' This is how i defined other aliases ... (4 Replies)
Discussion started by: erora
4 Replies

8. Shell Programming and Scripting

Bash script [Press Tab] Screen Blank..

Dear Member, OLD Question --> disable-completion not solved My bash Menu script ping process problem. If ping still running and users press SCREEN is Blank... Cant Members help me.. kill signal or others scripting for my case, btw i use Linux.. Thanks, Rico My Bash Script : ... (1 Reply)
Discussion started by: carnegiex
1 Replies

9. Programming

pthread_mutex_trylock() overwrites global variable on CentOS5

Hi all, I am new to linux and got problem with pthread_mutex_trylock(). I have used mutex in my code. When I try to call pthread_mutex_trylock() on RECURSIVE type of mutex it overwrites adjacent memory location (that is global variable of type structure say x, memory allocated using malloc()). ... (5 Replies)
Discussion started by: liveshell
5 Replies

10. HP-UX

Data protector GUI gives Blank screen

Hi, Haveing a little trouble with data protector (5.5) on HP-UX (11.11, 11.23) under Xwindows Chameleon UNIX 97 (7.0 - its a old version) I am trying to get the GUI for DP up and running on a HP-UX cell manager and I have the following problem. The GUI starts up with no errors that I can... (2 Replies)
Discussion started by: Andrek
2 Replies

Featured Tech Videos