Ampersand not giving back the control (Korn shell)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ampersand not giving back the control (Korn shell)
# 1  
Old 03-01-2012
Ampersand not giving back the control (Korn shell)

OS version : AIX 6.1
Shell : Korn

When you 'postfix' a command with ampersand (&) , it is supposed to run in the background and give you back the control.

I tested this with ping command (by default it pings every 1 second )

After I ran the below ping command with ampersand, I pressed enter and I got the $ prompt. But when I was about type the next command, the ping output keeps coming to prompt and I can't type anything.

To stop the execution , I tried Ctrl+z and Ctrl + C . But neither of them worked
Code:
[glxavr214]/$ ping glxavr196 &
[1]     29688082
[glxavr214]/$ PING glxavr196.qualx.net (169.165.0.114): 56 data bytes
64 bytes from 169.165.0.114: icmp_seq=0 ttl=255 time=0 ms
64 bytes from 169.165.0.114: icmp_seq=1 ttl=255 time=0 ms
64 bytes from 169.165.0.114: icmp_seq=2 ttl=255 time=0 ms

[glxavr214]/$ 64 bytes from 169.165.0.114: icmp_seq=3 ttl=255 time=0 ms
s64 bytes from 169.165.0.114: icmp_seq=4 ttl=255 time=1 ms

ksh: s:  not found
[glxavr214]/$ 64 bytes from 169.165.0.114: icmp_seq=5 ttl=255 time=4 ms

[glxavr214]/$ 64 bytes from 169.165.0.114: icmp_seq=6 ttl=255 time=0 ms

[glxavr214]/$ 64 bytes from 169.165.0.114: icmp_seq=7 ttl=255 time=0 ms

Why can't I get the control back at dollar prompt to run other commands?

Last edited by Scott; 03-01-2012 at 09:59 AM.. Reason: Code tags, please...
# 2  
Old 03-01-2012
Ping is sending its output to STDOUT, which is the screen. You can redirect it to go into a file instead:
Code:
ping glxavr196 > ping.out &

This User Gave Thanks to gary_w For This Post:
# 3  
Old 03-01-2012
Also you if you want to use ping in a script I suggest this approach :

ping -c X <hostname>

where X is number of packages (one per second) you want to send to the rmeote server. To check the ping for a server for a certain time-frame I preffer this approach rather than ping sent to background and then kill the background process.
This User Gave Thanks to black_fender For This Post:
# 4  
Old 03-01-2012
You have control of your terminal, but ping is still allowed to print to it, too.
This User Gave Thanks to Corona688 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing control back to the shell script

Hi All, I have a shell script(test_abc.sh) with the following shell commands, which are invoking the same shell script with different parameters. test_abc.sh . ./test.sh abc >> test.log . ./test.sh xyz >> test.log . ./test.sh pys >> test.log . ./test.sh abc >> test.log . . ... (4 Replies)
Discussion started by: dev.devil.1983
4 Replies

2. Shell Programming and Scripting

Sql command inside shell script runs without giving anything back as outout

#!/bin/sh # This script returns the number of rows updated from a function echo "The execution is starting ....." sqlplus -silent $UP <<EOF set serveroutput on set echo off set pagesize 0 VAR no_rows_updated NUMBER; EXEC :no_rows_updated :=0; DECLARE CURSOR c_update is SELECT * FROM... (4 Replies)
Discussion started by: LoneRanger
4 Replies

3. Shell Programming and Scripting

Shell command execution always giving zero as return value

Whenever the shell script is invoked by the scheduler the command execution return code is always captured as 0(Success). If the same shell script is executed in command line via unix terminal, the command execution return code's are captured properly. For example: ls -ltr es_wrong_file ---->... (5 Replies)
Discussion started by: vemal
5 Replies

4. Shell Programming and Scripting

Bourne shell & Korn shell

Could some one tell me the difference btw Bourne shell and the Kshell? Which is more flexible and reliable in terms of portability and efficiency. When i type the following command .. $ echo $SHELL yields me /bin/sh Does this tells me that I am in Bourne shell. If yes, how can i get... (6 Replies)
Discussion started by: bobby1015
6 Replies

5. Shell Programming and Scripting

Backup script using Korn Flow Control

I am wiping off the dust to my shell scipting days and had this question: I have this script that I have created, and cannot figure out where my flow control issue is within this script. #!/bin/ksh #Basic script to backup server #Home directories to the external ... (2 Replies)
Discussion started by: metallica1973
2 Replies

6. Shell Programming and Scripting

How to activate Korn Shell functionnalities in Bourne Shell

Hi All I have writing a Korn Shell script to execute it on many of our servers. But some servers don't have Korn Shell installed, they use Borne Shell. Some operations like calculation don't work : cat ${file1} | tail -$((${num1}-${num2})) > ${file2} Is it possible to activate Korn Shell... (3 Replies)
Discussion started by: madmat
3 Replies

7. Solaris

how to get back a SVM volume to solaris control

hi.., help me in this case... 1) now the disk is under disksuite, its have some mirrored volume. how can i get back this disk to OS control. 2) how can i know the a SVM volume avalable,used space. and the filesystem size on tht volume please help in this i am bigginer... (5 Replies)
Discussion started by: b.janardhanguru
5 Replies

8. Shell Programming and Scripting

mv command is giving error in shell script

Hi, In my shell script when I am using mv command using shell variables it is giving me error of syntax. Following is the shell script: file_edifice="*.txt" fquote="'" fdquote=\" for file in $file_edifice do file_name=$fquote$file$fquote tofile_name=`date... (5 Replies)
Discussion started by: gammit
5 Replies

9. Shell Programming and Scripting

how to convert from korn shell to normal shell with this code?

well i have this code here..and it works fine in kornshell.. #!/bin/ksh home=c:/..../ input=$1 sed '1,3d' $input > $1.out line="" cat $1.out | while read a do line="$line $a" done echo $line > $1 rm $1.out however...now i want it just in normal sh mode..how to convert this?... (21 Replies)
Discussion started by: forevercalz
21 Replies
Login or Register to Ask a Question