Linux / UNIX Tech Support Forum
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 ...
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
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 | ||
|
|
|
||||
|
Replace if [ -e filename ] with if [ -e filename ] ; then i.e.
Code:
#!/bin/bash clear if [ -e filename ]; then ./script_a else ./script_b fi exit if [ ]; then ... else ... fi
__________________
Vivek Gite Linux Evangelist |
|
|||
|
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 |
|
|||
|
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.. |
|
||||
|
./var => script name
$1 $2 $3 $4 $5 $6 $7 $8 $9 => All are command line args passed to this script
__________________
Vivek Gite Linux Evangelist |
![]() |
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 | 24-03-2008 09:52 PM |
| Adding storage function to a mail server | satimis | Databases servers | 0 | 04-01-2008 01:15 PM |
| bash history...suse 10.1 | grogf | Linux software | 4 | 30-10-2007 04:42 PM |
| -bash: /bin/ps: Cannot allocate memory | kasimani | Linux software | 1 | 12-10-2007 09:00 PM |
| Call Logging and Asset Mgmnt SW | ricc | Linux software | 1 | 29-06-2007 01:45 AM |