Bash Shell to sh Shell In a Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash Shell to sh Shell In a Script
# 8  
Old 08-29-2008
Quote:
Originally Posted by saurabh84g
Case1)
Bash-3.2#./abc.sh
Bash-3.2#

output)abc28Aug.lst == correct output===
When you run any shell script it spawns a new shell, so including an exit statement will have no effect, you will still be returned to the parent shell that you run it from (unless you "source" the script using . ./abc.sh).

Quote:
Originally Posted by saurabh84g
Case2) #./abc.sh

output) abc$$(date '+%d%b%y').lst ===wrong output=====
If you need to run the shell from sh, but have it interpreted by bash, then just add a shebang line as the first line of the script, e.g.

Code:
#!/usr/bin/bash
ping localhost > abc.sh$"$(date ' +%d%b%y')".lst

Also, I'm nost sure why you have the extra $"" around the date command, this should be enough:

Code:
#!/usr/bin/bash
ping localhost > abc.sh$(date '+%d%b%y').lst

# 9  
Old 08-29-2008
it is working

Quote:
Originally Posted by saurabh84g
Their is nOthing wrong with the Ping
the question is how to come to sh shell by running a script from bash shell .Smilie
HI Dear all
now it is working thanks for all the suggestions .
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed

In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed ? Is there any way to get the script names for the process command ? --- Post updated at 08:39 AM --- in KSH (Korn Shell), my command output shows the script names but when run in the Bash Shell... (3 Replies)
Discussion started by: i4ismail
3 Replies

2. Shell Programming and Scripting

Different behavior between bash shell and bash script for cmd

So I'm trying to pass certain json elements as env vars and use them later on in a script. Sample json: JSON='{ "Element1": "file-123456", "Element2": "Name, of, company written in, a very weird way", "Element3": "path/to/some/file.txt", }' (part of the) script: for s... (5 Replies)
Discussion started by: da1
5 Replies

3. Shell Programming and Scripting

Bash Shell Script

HELP!My program ends after entering one choice---need help making it take multiple inputs,instead of terminating after displaying just one #!/bin/bash# Crude address databaseclear # Clear the screen.echo " Contact List"echo " ------- ----"echo "Choose one of the following... (6 Replies)
Discussion started by: help123
6 Replies

4. Shell Programming and Scripting

Bash shell script- help

I need to invoke a program on remote server using ssh in a shell script. In addition i would like to capture date/time and if there is any errors , then script should write to log file. can someone please help me out? (1 Reply)
Discussion started by: sam101
1 Replies

5. Shell Programming and Scripting

Help with Bash Shell Script

I am fairly new to Unix scripting. A need has come where I need to to read the first column of a tab delimited file. The first column will be an id number and so I would need to read the first column one by one and create another file with only unique id numbers. So for example, if I have the... (14 Replies)
Discussion started by: khanvader
14 Replies

6. Shell Programming and Scripting

bash shell script

i want to monitor which users logged in to unix system if users who logged in more than once then store to a text file . any idea? (2 Replies)
Discussion started by: CheeSen
2 Replies

7. UNIX for Dummies Questions & Answers

Bash shell script

Hi Guys, I am trying to alter a script for my company. I need the start of it to go something like this. User is asked to input 8 numbers 8 numbers are written to a txt file ***** ***** ***** txt file is read ***** ***** The text file gets read in between other files represented by... (2 Replies)
Discussion started by: outthere_3
2 Replies

8. Shell Programming and Scripting

BASH Shell Script Help -HELP!

Im a newbie to shell scripting - in fact you could even call me a Linux newbie, well, mabye not i started with CYGWIN a year ago... but i only just recently wiped the Windoze partition off my drive. -Anyways, heres the script i have a problem with: #!/bin/bash # #PeMPcoder function... (2 Replies)
Discussion started by: flamethrower0
2 Replies

9. Shell Programming and Scripting

bash shell script

im trying to teach my self bash shell scripting. i want to include command line arguments in my script i am writing for practice. when i run my script it dosnt make a difference what arguments there are, it just out puts the error message as if there were none. here is the check_opts () function in... (4 Replies)
Discussion started by: norsk hedensk
4 Replies
Login or Register to Ask a Question