Exits from putty instead of shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Exits from putty instead of shell script
# 8  
Old 02-08-2011
Quote:
Originally Posted by methyl
Doesn't "exec" start a new Shell?
Hi Methyl, it does not start a new shell, see: exec: description
# 9  
Old 02-08-2011
Quote:
Originally Posted by Imran_Chennai
...
Is there any alternate way to establish log without exec & exit.
...
Maybe if you could tell us what exactly you are trying to do in your script, we might come up with a few suggestions.

Quote:
...I am using this logic for 4 inividual scripts (bash) that runs daily, two of them are for sqlldr and others calling SP. ...
Interaction of the shell with Oracle doesn't have to be complicated. But you got to help us help you here.

tyler_durden
# 10  
Old 02-08-2011
@Scrutinizer
Thanks.
Never found a use for " exec > $LOGFILE 2>&1 " but I see from the link you post how it might work but I cannot match the syntax used by the O/P with any of the examples.
We use "exec" to lock people into a shell menu (which does start a new shell). Any lines in the calling script below the "exec" line are never executed and the "drop-through" in the exec'd shell menu logs you out. That's what I though was happening to the O/P.
# 11  
Old 02-14-2011
I am just trying to capture all the echo comments. The script includes zipping and mailing which turnouts some system messages like below

adding: file1.csv (deflated 92%)
adding: file2.csv (deflated 46%)

redirecting to some o/p file on each single stmt may not be appropriate. I tried to simulate in simple code but again it quits the session after execution...
pls see below

Code:
user@server:/path> cat test.sh
#!/bin/bash

LOGFILE=/logpath/testlog.`date "+%y%m%d" `.$$
exec > $LOGFILE 2>&1

echo Line 1

echo Line 2

exit
user@server:/path>
user@server:/path>. test.sh

it exits from the session and need to relogin to see the log

Code:
user@server:/logpath> cat testlog.110214.3496
Line 1
Line 2
user@server:/logpath>

hope now my req is clear, appreciate for any alternate idea to get rid of this concept

Smilie
# 12  
Old 02-14-2011
Try:
Code:
chmod +x test.sh
./test.sh

You can just remove the exit statement by the way. It serves no purpose...
# 13  
Old 02-16-2011
Thanks a lot it really works with exit stmt as well.

by the way whats difference in dot space and other one.
# 14  
Old 02-16-2011
With dot space you are "sourcing" the commands in the script, which mean you execute them in your current environment, which is your interactive shell. The exit statement exits the shell which is your interactive shell, so your putty session gets terminated...

The other way is called executing and in this case a new shell is started in which the script is run. Once it exits, it only exits that shell and your interactive shell remains active...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Bash script to compare file all the files exits or not

Currently i am building a script like based on region parameter it will filter the records in config file and then it will create a text file like ab.txt and it will read the path location in that file and now i need to compare the files name in the config file to files in the path of the config... (1 Reply)
Discussion started by: saranath
1 Replies

2. UNIX for Beginners Questions & Answers

Script to check if files exits

Hi In live system core files are generating frequently. around 10 core files in 30 mins in root file system. which is eating my space very much below is core file core.56539 core.78886 core.12302 core.80554 core.20147 I am trying to write a script which should move... (7 Replies)
Discussion started by: scriptor
7 Replies

3. Shell Programming and Scripting

Script exits when using UNIX2dos / dos2UNIX

I'm not sure why but my script quits automatically at the point where unix2dos / dos2unix command is used. :confused::confused::confused: How do a fix it? LOG_FILE=MADDY.txt unix2dos ${LOG_FILE} exec 2> $LOG_FILE 1>&2 echo ${LOG_FILE} The script exists after the below... (3 Replies)
Discussion started by: machomaddy
3 Replies

4. Windows & DOS: Issues & Discussions

Method to run a shell script using shortcut key in keyboard with out logging to putty

Dear All, I want to run a shell script with out logging to putty but configuring it to a keyboard short cut it windows PC. Can this be done? I want this to rename a log in a specified folder in a system Thanks (8 Replies)
Discussion started by: Chi_SL
8 Replies

5. UNIX for Dummies Questions & Answers

Script dosent exits after executing the script

Hi i wrote a script which dosent exists after executing any help #!/bin/bash netstat -ptlen | grep 10000 if ; then echo "Hive Thrift server is running" exit 0 else echo "Hive Thrift server is down Trying to Bring up the service" | mail -s "ALERT" team@domain.com `nohup hive... (7 Replies)
Discussion started by: vikatakavi
7 Replies

6. Shell Programming and Scripting

ksh: hash (#) at beginning of a line exits the shell

This is WILD! :eek: Under Ubuntu (where I am cross-posting this problem) I have lately noticed by terminal windows/tabs closing unexpectedly. I finally caught it: I was composing a complicated command so I practices it a few times commented out - that is, with a # at the start of the line. What... (3 Replies)
Discussion started by: rpaskudniak
3 Replies

7. Shell Programming and Scripting

Shell scripts exits after executing ypmatch

Hello - I have a script which creates a NIS user on Solaris machine. Before creating the user I check if the user being created laready exists or not using ypmatch and use $? to get the exit code. If a user exists, I get 0, works fine. However when the user is not found, the shell scripts exits by... (1 Reply)
Discussion started by: manju--
1 Replies

8. Shell Programming and Scripting

'script' command exits immediately

I'm trying to capture the output of some commands with the 'script' utility. Normally, I would type 'script /path/to/output/file', then enter commands, then hit ctrl+D to end the 'script' capture. I'm having trouble with it on a server. Upon starting 'script', it exits immediately before I type... (6 Replies)
Discussion started by: jalburger
6 Replies

9. Shell Programming and Scripting

Renaming putty windows with a shell script

i frequently have to open multiple putty windows to ssh into a unix server running HP-UX 11.23. Since i use some of the windows for dedicated processes i would like to rename them (the caption displayed in the titlebar) to something more convenient than the standard <Host>.<Server>.com While... (4 Replies)
Discussion started by: orno
4 Replies

10. Shell Programming and Scripting

Script exits with $? not 0 randomly, how can I see what command failed?

Hi! I have this situation with 3 shellscripts. One is a "startscript" that simply calls other scripts. This one is scheduled with cron to run at regular intervals. That script runs what I'll refer to as Script 1. Script 1 in turn runs script 2 (import_catalogs_buyer.sh) Sometimes, seemingly... (2 Replies)
Discussion started by: trailsmoke
2 Replies
Login or Register to Ask a Question