Unix/Linux Go Back    


Solaris The Solaris Operating System, usually known simply as Solaris, is a Unix-based operating system introduced by Sun Microsystems. The Solaris OS is now owned by Oracle.

Exec command - different output

Solaris


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 07-15-2017
s_premkumar s_premkumar is offline
Registered User
 
Join Date: Jul 2017
Last Activity: 16 July 2017, 9:45 PM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Exec command - different output

Hi Guys, I am trying to to execute the below script in two different machines
Code:
#!/bin/ksh
###############################################################################
# File : pause
###############################################################################
print "\nPlease Press \033[4m\033[0m to continue\c"
read answer

Its resulting the below output.

Code:
prem@host1:exec pause 2>> /tmp/prem.log
Please Press <Enter> to continue Connection to host1 closed.
prem@host1:
prem@host2:exec pause 2>> /tmp/prem.log
Please Press<Enter>  to continue
Connection to host2 closed.
prem@host2:

. When I execute the command in host1 its not waiting for input. Any idea friends? Thanks Prem


Moderator's Comments:
Exec command - different output Please use CODE tags as required by forum rules!
And, seriously, invest some care to structure the text legibly so people can read and understand it ad hoc!

Last edited by s_premkumar; 07-16-2017 at 09:23 PM.. Reason: Words missing. Line break not required.
Sponsored Links
    #2  
Old Unix and Linux 07-15-2017
PikK45 PikK45 is offline
Registered User
 
Join Date: Jul 2012
Last Activity: 15 July 2017, 9:15 AM EDT
Location: Chennai
Posts: 581
Thanks: 51
Thanked 75 Times in 73 Posts
Is this Solaris? Are the two servers are of same *nix flavors?
Sponsored Links
    #3  
Old Unix and Linux 07-15-2017
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 21 October 2017, 2:19 AM EDT
Location: In the leftmost byte of /dev/kmem
Posts: 5,612
Thanks: 106
Thanked 1,598 Times in 1,176 Posts
Quote:
Originally Posted by s_premkumar View Post
Its resulting the below output.

Code:
prem@host1:exec pause 2>> /tmp/prem.log
Please Press  to continue
Connection to host1 closed.
prem@host1:
prem@host2:exec pause 2>> /tmp/prem.log
Please Press  to continue
Connection to host2 closed.
prem@host2:

. When I execute the command in host1 its not waiting for input. Any idea friends?
I can't tell you why it isn't waiting on host1, but i suppose it is simply not there (or not in the path, not flagged executable, ....). I can tell you, though, why your connection to the host is closed afterwards:

Normally, when you start a process B from another process A , A sets up B as its "child process": B will be started, executed and when it ends, its return value will be presented to A for evaluation.


With the command exec this changes: A, in fact, will start B in its own environment (the one of A) and the exit immediately so that B effectively replaces A. Because you replaces your login shell with the little script you wrote (which in turn ended) your connection was simply closed the same way it would have been if you had ended the login shell otherwise (like by pressing "CTRL-D", entering "exit", etc.).

I hope this helps.
bakunin
The Following User Says Thank You to bakunin For This Useful Post:
jim mcnamara (07-15-2017)
    #4  
Old Unix and Linux 07-16-2017
s_premkumar s_premkumar is offline
Registered User
 
Join Date: Jul 2017
Last Activity: 16 July 2017, 9:45 PM EDT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by PikK45 View Post
Is this Solaris? Are the two servers are of same *nix flavors?
Dear Friend,

Yes both are Solaris 10 servers with same OS/patch levels.

Thanks
Prem.

---------- Post updated at 08:45 PM ---------- Previous update was at 08:25 PM ----------

Hi Bakunin,

Thanks for your response. I am not worried about the connection drop.

When I hit enter to execute the command its resulting some like below.


Code:
prem@host1:exec pause 2>> /tmp/prem.log
Please Press <Enter> to continueConnection to host1 closed.

Is this something related to my input/keyboard settings?. I am expecting the program to wait for enter continue. However its reading the previous key press and exiting.

Thanks for your help.

Cheers,
Prem.

Moderator's Comments:
Exec command - different output edit by bakunin: you have been told to use CODE-tags. Please pay heed to what you are told.

Last edited by bakunin; 07-17-2017 at 05:42 AM..
Sponsored Links
    #5  
Old Unix and Linux 07-17-2017
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
 
Join Date: May 2005
Last Activity: 21 October 2017, 2:19 AM EDT
Location: In the leftmost byte of /dev/kmem
Posts: 5,612
Thanks: 106
Thanked 1,598 Times in 1,176 Posts
Quote:
Originally Posted by s_premkumar View Post
Is this something related to my input/keyboard settings?. I am expecting the program to wait for enter continue. However its reading the previous key press and exiting.
This might have something to do with your terminal settings. It is definitely NOT related to the exec command as the title suggests: the command doing the reading from the keyboard is the read.

read is a shell-builtin command and the difference in behavior might also come from different shell versions and similar differences. You might want to leave out the exec to investigate, so that you don't have to reconnect for every single attempt.

In general, though, i can't understand the reason why you are doing what you do at all. Could you please describe what you are trying to achieve - maybe there is a better/faster/more elegant way to achieve it anyways.

I hope this helps.

bakunin
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Several exec on find send all the output to the last redirection Tribe Shell Programming and Scripting 2 12-12-2014 03:16 PM
Output redirection to exec does not work Gokul Kumar G Shell Programming and Scripting 8 05-25-2010 12:11 PM
Help! Paste Multiple SQL output result to exec command jackyntk Shell Programming and Scripting 0 10-09-2009 12:25 AM
Capturing the output from an exec command avik Shell Programming and Scripting 1 11-07-2008 03:09 AM
Hi How to redirect the output of exec nathgopi214 Shell Programming and Scripting 2 03-23-2008 08:10 AM



All times are GMT -4. The time now is 04:18 AM.