1833876 Members
1690 Online
110063 Solutions
New Discussion

show column in script

 
SOLVED
Go to solution
ust3
Regular Advisor

show column in script

I have a applicaton , when run /tmp/my_script , that will output the result to the screen ( as below ) , the output is very long ( about 1500 lines ) , I have a program ( as below ) that will show the output with function 1 > 1 , it works fine , however , the output only show page 1 of this 1500 lines ( round 60 lines output is shown ) , can advise what is wrong , how to output all 1500 lines ? besides , if I want the output only have fisrt two column ( date & time in my case ) , the number column do not show , can advise how to change my program ? thx in advance.



the result
======
04/15/07 01:00:00 1 8 7 8 5 8 4 5 5 7
04/15/07 02:00:00 1 2 58 7 5 6 4 1 8
"
"
"
(total 1500 lines )


My program
=======
#vi /tmp/my_program
#/bin/ksh
/tmp/my_script <sleep 1
sleep
1
EOF
9 REPLIES 9
Lexxx
Advisor
Solution

Re: show column in script

if you want to show the first two columns just add awk {'print $1, $2'} filename in your script.

ust3
Regular Advisor

Re: show column in script

thx reply ,

for my first question , why it only show the page 1 , it is because it is wait to press "enter" key to next page , can advise if I want to add the "enter" command to my program , what can i do ? thx

#vi /tmp/my_program
#/bin/ksh
/tmp/my_script <sleep 1
1
"enter"
"enter"
sleep 1
1
EOF
Dennis Handly
Acclaimed Contributor

Re: show column in script

It appears you have an interactive program that expects a user to select which page or how many?

Ideally, your program should just dump 1500 lines and let the caller pipe it through more if he wants paging or though awk if he wants to select columns.

But with your "sleep" inputs, it seems you want it to wait before some output?

If you don't want it to stop after a page, it seems the best thing to do to your application is to pass a flag (or set and env var), to say you don't want paging.

>it is because it is wait to press "enter" key to next page, can advise if I want to add the "enter" command to my program, what can i do?

I assume you just have ~1500/60 blanks lines to simulate the ENTER key.
ust3
Regular Advisor

Re: show column in script

thx reply


But with your "sleep" inputs, it seems you want it to wait before some output? << - no, I set "sleep" only want it run more smoothly ( i guess it is the case ) , please ignore it.

If you don't want it to stop after a page, it seems the best thing to do to your application is to pass a flag (or set and env var), to say you don't want paging --> please advise how to set this env ?

thx
Dennis Handly
Acclaimed Contributor

Re: show column in script

>please advise how to set this env?

My suggestion was to change your application to detect a new command line option and do things differently. Or call getenv(3) to detect you don't want to do paging.
ust3
Regular Advisor

Re: show column in script

thx reply,

My suggestion was to change your application to detect a new command line option and do things differently. Or call getenv(3) to detect you don't want to do paging. -->

sorry , I am not too understand , can you please advise what I need to do ? thx
Dennis Handly
Acclaimed Contributor

Re: show column in script

>can you please advise what I need to do?

Can you change your application? Do you have the source and know how to build it?

I.e. you don't like how it works, can you change it so you can get all those 1500 lines?
ust3
Regular Advisor

Re: show column in script

Can you change your application? Do you have the source and know how to build it?

--> this is third party program , we don't have source code .


I.e. you don't like how it works, can you change it so you can get all those 1500 lines?

--> I can get all those 1500 lines but the application need to press "enter" key when I want go to next page ( 1500 lines have many pages ) , so I want to ask how to add the enter to my program , just like some unix key ^M etc.

Thx
Dennis Handly
Acclaimed Contributor

Re: show column in script

>this is third party program, we don't have source code.

So my suggestion isn't applicable.

>so I want to ask how to add the enter to my program, just like some unix key ^M etc.

Basically having blank lines in your here document will act the same as an enter key.
In the places above where you had "enter".