prompt within awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting prompt within awk
# 1  
Old 03-07-2007
prompt within awk

I have a script part of which runs awk, I'd like to put a prompt within the awk section (something along the ines of continue), I can run the system() command e.g., system("clear") to clear the screen, however if I try something like system("echo enter to continue \c l read ans") I get nothing other than stty: tcgetattr: Not a typewriter (which also shows prior to clear but still clears screen), is there an alternative to do this ?
# 2  
Old 03-07-2007
Code:
  printf("Enter to continue");
  getline ans < "-"

# 3  
Old 03-07-2007
Thanks for the help, the Enter to continue prints correctly now, however there is no pause for input ?
# 4  
Old 03-07-2007
Tried this on SUN

awk 'BEGIN{printf("Enter to continue: ");
getline ans < "-"
print ans
}'
Enter to continue: xxxxxxx
xxxxxxx


worked fine

Are you using Standard input for some other purpose? That would defeat this program.
# 5  
Old 03-07-2007
Quote:
Originally Posted by gefa
Thanks for the help, the Enter to continue prints correctly now, however there is no pause for input ?
If on Solaris, make sure to use 'nawk' (not 'awk')

nawk -f gefa.awk myInputFile

gefa.awk:
Code:
{
  printf("Enter to continue")
  getline ans < "-"
  printf("ans->[%s] line->[%s]\n", ans, $0)
}

# 6  
Old 03-07-2007
Hi this is my code (I'm on AIX 5.3) if it's of any help;

awk -F, < $aclocat '
{
{ if ($1 ~ "Locat") {col1=$1 ; col2=$2 ; col3=$3 ; col4=$4 ; col5=$5 ; col6 = $6 ; col7 = $7 ; col8=$8 ; col9=$9}
if (substr($1,1,5) != "locat") {
if (mycount < 45)
{
printf "%-8s %-7s %-3s %-8s %-9s %-3s %-8s %-6s %-16s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9
}
else {
mycount = 1
printf("Enter to continue");
getline ans < "-"


printf "%-8s %-7s %-3s %-8s %-9s %-3s %-8s %-6s %-16s\n",col1,col2,col3,col4,col5,col6,col7,col8,col9
}
}
mycount++
}
}'
# 7  
Old 03-07-2007
try loosing the '<' on cli:
Code:
awk -F, $aclocat

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Unable to move from rsc prompt to ok prompt

Hi, on sunfire v890 unable to move from rsc prompt to ok prompt, i have executed the command break. (9 Replies)
Discussion started by: manoj.solaris
9 Replies

2. UNIX for Dummies Questions & Answers

How to Change the % prompt to - prompt in UNIX?

how to Change the % prompt to - prompt in unix :wall: ---------- Post updated at 07:40 AM ---------- Previous update was at 07:38 AM ---------- How To display the last modification time of any file in unix ---------- Post updated at 07:40 AM ---------- Previous update was at 07:40 AM... (2 Replies)
Discussion started by: manjiri sawant
2 Replies

3. Shell Programming and Scripting

awk command in script gives error while same awk command at prompt runs fine: Why?

Hello all, Here is what my bash script does: sums number columns, saves the tot in new column, outputs if tot >= threshold val: > cat getnon0file.sh #!/bin/bash this="getnon0file.sh" USAGE=$this" InFile="xyz.38" Min="0.05" # awk '{sum=0; for(n=2; n<=NF; n++){sum+=$n};... (4 Replies)
Discussion started by: catalys
4 Replies

4. Solaris

No prompt!

We have a Solaris 10 machine. Today a weird issue happened. After login remotely via ssh, the motd appeared BUT there was no prompt! The prompt only appears after pressing Ctrl+d or Ctrl+c. Strange behaviour. I have checked /etc/profile and own user .profile, there is no anamoly. ... (11 Replies)
Discussion started by: sundar63
11 Replies

5. Solaris

ok prompt

There is a number before the ok prompt in OBP between brackets {}. It is 0 most of the time but sometimes it is different number {9} ok or {0} ok What does this number mean and how it gets changed? (3 Replies)
Discussion started by: StarSol
3 Replies

6. Shell Programming and Scripting

How to a prompt a particular value???

Hi i am working with clearcase in my UNIX machine... Accidentally some had ran a script to check out all files in the machine.... Now i am actually trying to uncheck out all those files and had written a script for it.... The problem is that when ever i am trying to uncheck out the files, its... (2 Replies)
Discussion started by: grajesh_955
2 Replies

7. Solaris

OK prompt

Here is a silly question: I have a Sun 220R and I need to get to the OK prompt. I can't hook up a monitor and keyboard to it. Its on a KVM right now and I also have a console connected to it. I can use PuTTY to get to the console and then connect to the 220R from there. How can I get to the... (3 Replies)
Discussion started by: hshapiro
3 Replies

8. Solaris

Can't get ok prompt

Hi, I'm attempting to reinstall a damaged installation of Solaris 9 (on a SunFire). Connected via serial from a PC. Can't get to the "ok" prompt to launch install from CD. Ctrl+break acknowledges my request for a break, but no prompt. "#." gets me an "sc>" prompt, with several options, but... (3 Replies)
Discussion started by: shonenfan
3 Replies

9. UNIX for Dummies Questions & Answers

prompt why ?

Even though I give rm -f *, the files are listed for confirmation of removal . Why ? Thanks LS (2 Replies)
Discussion started by: ls1429
2 Replies

10. UNIX for Dummies Questions & Answers

prompt

how do we change the command prompt? right now my prompt says felix% where felix is the machine i´m on. but how do we change it? for example, how can i make it say me% and how do we get it to tell us what directory we are under because when i change into a subdir then the prompt... (1 Reply)
Discussion started by: eeldivady
1 Replies
Login or Register to Ask a Question