Executing 'exit' command from shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing 'exit' command from shell script
# 1  
Old 12-13-2014
Executing 'exit' command from shell script

Hi,

I am writing shell script to automate few use cases for CLI interface. We have CLI interface which has bunch of commands. I am trying to execute one of the commands 'exit' as part of automation to exit from CLI object (not from shell script) in my shell script.

My intension is to execute 'exit' command on CLI as part of some automation, I do not want to exit from shells script.

The issue is, when I execute 'exit' command on CLI interface, shell script thinks that it is the 'exit' command to exit from shell script which is obvious but I am trying to see what can be the option which will run 'exit' command on CLI but that will not exit from my shell script.

Any help would be much appreciated!

Thanks,
# 2  
Old 12-13-2014
Are you saying you want your script to run as a daemon? Are you in linux?
# 3  
Old 12-14-2014
Does your CLI have an exit function?

It sounds like your CLI is supposed to do command line preprocessing, then the result is passed back to the shell, except the preprocessor has no visible exit function defined when you run it. Note that exit is a builtin command for some shells. By that I mean it may not be possible to bypass the command exit, unless there is a way to disable the shell builtin.

Last edited by jim mcnamara; 12-14-2014 at 07:39 AM..
# 4  
Old 12-14-2014
Note that in the standards, exit is a special built-in (which means that there is no PATH lookup for it and there is frequently no way to override or disable it).
# 5  
Old 12-14-2014
If you want to run something like "/usr/local/bin/exit", you need to specify the entire path. Trying to invoke it with just "exit" will invoke the shell built-in command even if "/usr/local/bin" is in your path envval. And that causes the shell to exit.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to keep staying on remote server after executing a shell script with if then exit end statement?

i have a "if .. then exit end " in s shell script on remote servers. now the connection to the remote server got killed after i run this script on the remote servers. How do i run this script on remote hosts and still keep remote connections alive after executing the script. Thank you. (10 Replies)
Discussion started by: moonmonk
10 Replies

2. UNIX for Beginners Questions & Answers

Linux shell | how to exit a script if any command fails.

Hi, i am new here let me say HI for all. now i have a question please: i am sending one command to my machine to create 3 names. if one of the names exists then the box return error message that already have the name but will continue to create the rests. How i can break the command and... (7 Replies)
Discussion started by: Amiri
7 Replies

3. UNIX for Dummies Questions & Answers

Execute shell script and if string found while executing then exit

Hi All, I have one shell script start.sh which executes another shell script test.sh something like below :test.sh -param1 -param2 In the test.sh there is one command for removing file:rm file1.bak I want whenever I execute start.sh, it will execute test.sh and if it finds string rm... (7 Replies)
Discussion started by: ORAI
7 Replies

4. UNIX for Dummies Questions & Answers

Cron shell script not executing diskutil command

I'm trying to learn how to use cron for repetative tasks. I have an external disk that needs to be unmounted and remounted every hour due to some problems that a backup utility (specifically, TimeMachine) is having repeatedly accessing the device. I've created a shell script that will find the... (3 Replies)
Discussion started by: illuminate
3 Replies

5. Shell Programming and Scripting

How to exit a shell script if a unix command does not return any value for 10 seconds?

Hi, Can anyone help me how to exit a shell script if a unix command inside does not return any value for 10 seconds? The scenarios is like this. I want to login to a application using shell script where the connection string is mentioned.but suppose this connection string is not... (10 Replies)
Discussion started by: arijitsaha
10 Replies

6. Shell Programming and Scripting

store last command exit status in variable in shell script

Hello All My req is to store the exit status of a command in shell variable I want to check whether the file has header or not The header will contain the string DATA_ACQ_CYC_CNTL_ID So I am running the command head -1 $i | grep DATA_ACQ_CYC_CNTL_ID Now I have to check if... (6 Replies)
Discussion started by: Pratik4891
6 Replies

7. Shell Programming and Scripting

problem in exit status of the command in a shell script-FTP

Hi All, I have developed below script for FTP a file from unix machine to another machine. ftpToABC () { USER='xyz' PASSWD='abc' echo "open xx.yy.zbx.aaa user $USER $PASSWD binary echo "put $1 abc.txt" >> /home/tmp/ftp.$$ echo "quit" >> /home/tmp/ftp.$$ ftp -ivn <... (3 Replies)
Discussion started by: RSC1985
3 Replies

8. Shell Programming and Scripting

Error executing shell command from a perl script

Hi Gurus, I've a find command that gets the list of files from a source directory where the extension is not html, xml, jsp, shtml or htaccess. The below find command runs fine from the command prompt or in a shell script. I need to eventually run it in a PERL script and am getting the... (5 Replies)
Discussion started by: voorkey
5 Replies

9. UNIX for Dummies Questions & Answers

using exit command in a shell script

Can it be done? If so, how? I would like a script to contain the exit command, and log me off at script completion. thanks (1 Reply)
Discussion started by: jpprial
1 Replies
Login or Register to Ask a Question