This is a discussion on couple of noob questions within the Shell scripting forums, part of the Development/Scripting category; Is it best to wright menu driven script all in one file of link it to different scripts If linking ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
Is it best to wright menu driven script all in one file of link it to different scripts
If linking how do that ? Is there away when a script exits to leave you in the directory the script it self was last in b4 exit instead of returning you back to to dir you where in when you started script. ie.. start script in \home script runs and change dir a few time finishing in \home\whatever script exits and your shell returns prompt back in \home how do get prompt back so you are still in \home\whatever Is there away to kill processes without the pid No ie process name |
| Sponsored Links | ||
|
|
|
||||
|
Quote:
function.sh Code:
function a(){
echo "I am a()"
}
function b(){
echo "I am b()"
}
Code:
#!/bin/bash source function.sh a b Quote:
|
|
|||
|
I was just playing about right silly little short cut type scripts to help manage out server
heres two silly examples that did not work Code:
echo -e "changing directory" cd /var/www/html ls | more But when script exits i u return to dir where u started script from. Then i wrote 3 little scripts for TeamSpeak one checks status one stops but the 3rd which should restarted ts did not work. The first 2 are all run as root and they work fine but the 3rd changes users and does not work.. Code:
cd /home/ts/tss2_rc2 su ts ./teamspeak2-server_startscript start Just some silly little thing i was playing about with not inportant just help you learn and move on to biggger things |
|
|||
|
Hmm...
I just tested your current directory problem in script. You are right script does not remember changed directory location May be some one here should able to solve your problem |
|
|||
|
I Think i no why but i wonder what the way round it is
When you open terminal that is for example your login shell, when you run a script it opens a new shell and your login goes into hibernation if you like when script finishes that shell shuts and put's you back in login shell That what i think happens i am probably way off |
|
||||
|
When a child process is created (your script), it copy of its variables and current directory. So the child (your script) can change these values all it wants but the changes won't affect the parent shell, since the child is changing a copy of the original data.
As you said use Code:
. scriptname |
|
||||
|
sparky thanks for sharing back your solution with us
Monk nice clarification about . scriptname command
__________________
Rocky Jr. You may have my body & soul, but you will never touch my pride! If you have knowledge, let others light their candles at it. Certified to work on HP-UX / Sun Solaris / RedHat |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Real Interview Questions | Ashish Pathak | The Hangout | 15 | 10-20-2008 11:54 PM |
| Linux Administrator Interview Questions | jhn_daz@yahoo.com | Linux software | 4 | 08-19-2008 10:53 AM |
| Complete NOOB need help | gham | Shell scripting | 0 | 06-04-2007 10:56 PM |
| RHCE sample questions require | puppen | Linux software | 3 | 04-13-2006 07:36 PM |
| few quick perl questions | raj | All about FreeBSD/OpenBSD/NetBSD | 1 | 06-30-2005 01:27 AM |