This is a discussion on call function in bash within the Shell scripting forums, part of the Development/Scripting category; hi all, i have a problem, i did search around but end up disappointed. lets say i have 3 scripts ...
|
|||||||
| Register | FAQ | Members List | Calendar | Forgotten your password? | Mark Forums Read |
|
|||
|
hi all,
i have a problem, i did search around but end up disappointed. lets say i have 3 scripts script_a, script_b and script_c. all this script is saved in the same directory what if i want to call script_a and script_b inside a script_c i've test this way; #!/bin/bash clear if [ -e filename ] ./script_a else ./script_b fi exit but then, i cant call the ./script_a and ./script_b. the error message show that there is unexpected before else. how am i going to do this? |
| Sponsored Links | ||
|
|
|
|||
|
another problem...
i want user to enter a file name.. then i want to check whether the file is exist or not in home directory.. if exist.. copy to new file.. i wrote this way, but its not working... #!/bin/bash echo "Enter filename:" read filename cd /home/ if [ -e $filename ] then cp $filename /home/script/filename2 else echo "The file not exist" fi the result: unexpected .... before else |
|
||||
|
Quote:
Quote:
script_a code with foo() function Code:
#!/bin/bash
function foo(){
echo "I am foo()"
}
Code:
#!/bin/bash source script_a foo |
|
|||
|
hehe
what a shame... it was my fault.. i should write this way #!/bin/bash echo "Enter filename:" read filename if [ -e $filename ] then cp /home/$filename /home/script/filename2 else echo "The file not exist" fi thanks monk about calling a function u really give me an idea, i'm gonna test that.. |
![]() |
| Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bash not working! | Mwalimugini | Getting started tutorials | 4 | 03-24-2008 10:52 PM |
| Adding storage function to a mail server | satimis | Databases servers | 0 | 01-04-2008 02:15 PM |
| bash history...suse 10.1 | grogf | Linux software | 4 | 10-30-2007 05:42 PM |
| -bash: /bin/ps: Cannot allocate memory | kasimani | Linux software | 1 | 10-12-2007 10:00 PM |
| Call Logging and Asset Mgmnt SW | ricc | Linux software | 1 | 06-29-2007 02:45 AM |