Run a single script in different shell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Run a single script in different shell
# 1  
Old 07-23-2010
Question Run a single script in different shell

Hi All,

I am new in UNIX.I have a situation here.Smilie
I have a script which have to be run in every shell (like KSH,BASH,CSH).
Script may be any thing.
But i don't know how to do it.Because the syntax of every shell may be different.


Please advise..
Thanks for your kind advise in advance.
# 2  
Old 07-23-2010
IMO - this cannot be a sane requirement for business purposes. It has to be homework.
Or the result of completely uninformed management run amok.

One single set of script language lines is going to have lots of problems running under csh and then bash/ksh. A probably not very useful script made entirely of unix commands will work

Code:
/usr/bin/ls /home/jdash.ps
/usr/bin/date
/usr/bin/printf "%s\n"  "hi there"


What are you trying to do? I
# 3  
Old 07-23-2010
There is too much difference in the syntax between "csh" and the various Bourne-like shells to write common shell code.
The usual approach is to put a shebang line at the front of the script to force the site standard shell regardless of the parent shell.
For example:

Code:
#!/bin/ksh

This may not be what you meant.
# 4  
Old 07-25-2010
Bug reply to answers

Hi all,

Thanks for the answer.
Jim and methyl you both are quite right.Smilie


but the requirement is like that.
I have to run the script in ksh and bash in both shell .U can leave "Csh".its not necessary.

That's why my question : Is there any common syntax for writing the script to be run in both shell.Smilie
# 5  
Old 07-26-2010
It's not easy.

Some would say invoke Posix mode in bash and then only use syntax which is common to ksh. The really big differences come with the external commands and you will inevitably have to test for the Operating System version before issuing some commands.


One of many sites which list differences between various Bourne-like shells, shell constructs and external commands.
Portable Shell - Autoconf
# 6  
Old 07-26-2010
MySQL Thanks..

Thanks methyl u r just too good...Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. UNIX for Beginners Questions & Answers

A single script to run multiple scripts

Hi , Can someone help! I need a shell script to run multiple scripts by using single shell script, incase any one of the scripts fails, it should get exit and after trouble shooting if we re-execute it, it should start from the failed script. I have a written a scripting till the... (1 Reply)
Discussion started by: anniesurolyn
1 Replies

3. Shell Programming and Scripting

How to run the multiple scp from single script?

Dear Experts, how to run multiple scp commands from single scripts. In a directory oracle redo files accumulate. i would like to copy those redo logs to my standby server. For same i am using scp to copy the files. where i am monitoring that as it is sending the files sequentially most of... (1 Reply)
Discussion started by: nmadhuhb
1 Replies

4. Shell Programming and Scripting

Run a shell script from one host which connext to remote host and run the commands

I want to write a script which would run from one host say A and connect to other remote host B and then run rest of commands in that host. I tried connecting from A host to B with SSH but after connecting to host B it just getting me inside Host B command prompt. Rest of the script is not running... (6 Replies)
Discussion started by: SN2009
6 Replies

5. Shell Programming and Scripting

How to run cmds after changing to a new env (shell) in a shell script

Hi, I am using HP-UNIX. I have a requirement as below I have to change env twice like: cadenv <env> cadenv <env> ccm start -d /dbpath ccm tar -xvf *.tar ccm rcv .... mv *.tar BACKUP but after I do the first cadenv <env> , I am unable to execute any of the later commands . ... (6 Replies)
Discussion started by: charlei
6 Replies

6. Shell Programming and Scripting

Help need to make a shell script run for ffmpeg vhook watermaking in shell

i have a small problem getting a batxh shell script to run in shell this is the code the problem seems to be centered around the ffmpeg command, something maybe to do with the ' ' wrapping around the vhook part command this is a strange problem , if i take the ffmpeg command and... (1 Reply)
Discussion started by: wingchun22
1 Replies

7. Shell Programming and Scripting

How to Run a shell script from Perl script in Parent shell?

Hi Perl/UNIX experts, I have a problem in running a shell script from my perl script (auto.pl). I run the perl script using perl auto.pl from the shell prompt The shell script picks the files in "input" folder and procesess it. The shell script blue.sh has this code. export... (16 Replies)
Discussion started by: hifake
16 Replies

8. Shell Programming and Scripting

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... (2 Replies)
Discussion started by: hkapil
2 Replies

9. Shell Programming and Scripting

single input shell script?

hey, i'm trying to write a shell script which accepts: operand operator operand then, the script would see which operator it is (using case) and calculate it... but i dont know how to do it correctly with $1 $2 $3... (eliminating accepting separate inputs) (1 Reply)
Discussion started by: quipy
1 Replies
Login or Register to Ask a Question