![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| rlogin inside a c-shell script | sumitgarg | Shell Programming and Scripting | 5 | 02-01-2008 12:27 AM |
| writing Enter key inside in shell script | bishweshwar | Shell Programming and Scripting | 3 | 01-04-2008 12:45 PM |
| How to run an SQL script inside a shell | stevefox | Shell Programming and Scripting | 1 | 06-15-2006 10:11 PM |
| ftp files inside a shell script | matrix1067 | Shell Programming and Scripting | 5 | 02-07-2006 05:31 PM |
| Using tar inside a shell script | kas7225 | Shell Programming and Scripting | 2 | 05-19-2005 11:06 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
How to run unix commands in a new shell inside a shell script?
Hi ,
I am having one situation in which I need to run some simple unix commands after doing "chroot" command in a shell script. Which in turn creates a new shell. So scenario is that - I need to have one shell script which is ran as a part of crontab - in this shell script I need to do a "chroot" to some particular directory . - After chroot I need to run some unix command. Here is the script ***************************************** #!/usr/bin/ksh cd /safedir/rdns/opt/MKDownload #java MKProcessor Val=`diff /safedir/rdns/opt/MKDownload/sun.csv /safedir/rdns/opt/RDNS1.1/WEB-INF/lib/sun.csv |wc -l` if [ $Val -gt 0 ]; then ( # `mv /safedir/rdns/opt/RDNS1.1/WEB-INF/lib/sun.csv /safedir/rdns/opt/RDNS1.1/WEB-INF/lib/sun.csv.bak` # `cp /safedir/rdns/opt/MKDownload/sun.csv /safedir/rdns/opt/RDNS1.1/WEB-INF/lib` /usr/sbin/chroot /safedir/rdns /bin/sh ------------------1 echo `pwd` -------------------------------------- 2 cd /opt/iws61/https-rdns/ ./stop ./start ) fi ***************************************** So as apparent from script , after chrooting in line 1 , it creates a new shell and the execution of this script suspends there. As soon as I 'exit' the shell the remaining commands from line 2 onwards execute in current shell and I get error. But as per my requirement the remaining commands need to run from chrooted directory only i.e new shell created as a result of command at line 1. Please provide any insight how to solve this ? Thanks in advance HKapil |
|
||||
|
Thanks it worked
Thanks Prederabo !!!!,
It worked for me... The remaining commands ran in the newly created shell.. Thanks again ... hkapil |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| unix commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|