How to run a bash script in csh shell?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to run a bash script in csh shell?
# 1  
Old 04-07-2011
How to run a bash script in csh shell?

Code:
Hi
how to execute a bash script in csh shell?

Thanks

# 2  
Old 04-07-2011
type :

Code:
which bash

at command prompt,

add at the start of shell script the path along with "#!" , in my unix box it is

Code:
 
#!/usr/bin/bash
...
your shell script
...

# 3  
Old 04-08-2011
Code:

Code:
problem:


A simple script:

#!/bin/bash
    echo "Ciao Grande Vito"
  echo "$1"
  echo "Inserisci un nome"
  read nome
  echo "$nome"
    exit 0


If I execute this script in a bash shell:
./script hallo
it print Hallo and print that I typed.


If I execute thi script in a csh shell:
It print Hallo and

nome: undefined variable



Thanks


# 4  
Old 04-08-2011
Hence , always try to execute using "bash" in another way.

Code:
 
bash script_name.sh

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to run ksh script in bash shell?

Hi All, I have few bash shell scripts which depends on one Ksh shell script. When i run bash shell scripts, it shows error as bad interpretor : ksh no such bad file or directory. When i tried to install ksh shell, it is not downloading too. If I remove !/bin/ksh command in starting line of the... (14 Replies)
Discussion started by: Karthik03
14 Replies

2. Shell Programming and Scripting

How to make a bash or shell script run as daemon?

Say i have a simple example: root@server # cat /root/scripts/test.sh while sleep 5 do echo "how are u mate" >> /root/scripts/test.log done root@server # Instead of using rc.local to start or another script to check status, I would like make it as daemon, where i can do the following: ... (2 Replies)
Discussion started by: timmywong
2 Replies

3. Ubuntu

error LD: undefined variable while changing shell from bash to csh

Hi, i am a beginner in ubuntu. my default shell is bash. everytime i try to change the shell with command "csh", i get a message (probably an error message). after i get into c-shell, when i try to execute a c shellscript, then it showed the same message. any idea about what is this about or any... (1 Reply)
Discussion started by: Avinash Nayak
1 Replies

4. Shell Programming and Scripting

How to run a file in a csh script?

Hi, I have a csh script. I want to set some variables and execute some command from a file in that script. abc.csh echo "primary script" b setenv XXX ddd set XX make abc I want to execute the commands of "b" file from abc.csh. How can i do that. Please view this link: How to use... (3 Replies)
Discussion started by: vdhingra123
3 Replies

5. Shell Programming and Scripting

How to run csh environment parameters from k-shell script?

Hi Guys, I need to run an alias from a k-shell script ,for example 10204, which points to : source $ORACLE_BASE/scripts/cshrc/10204/.cshrc Meaning , I need to run in my k-shell script with the env settings parameters of the alias. How to do it in k-shell? Thanks in advance, Nir (2 Replies)
Discussion started by: nir_s
2 Replies

6. Shell Programming and Scripting

HOW to run a bash-code in a c-shell script ??

Is there a way to run some code in a C-shell script by different shell, like bash? I have that situation. I have prepared and perfectly workable bash-skript that now I have to execute under C-shell script, divide it on steps and without creating a new files (with the bash-code parts.) For... (6 Replies)
Discussion started by: alex_5161
6 Replies

7. UNIX for Dummies Questions & Answers

Tcl script wont run in bash shell

Hello I'm having a problem running a TCL script in my new OpenSolaris OS. When I go to the directory containing my script called 'Install' (using the gnome terminal), it doesn't seem to be able to find it even though it lists it i.e. if I type "Inst" and hit tab to complete the word, it... (11 Replies)
Discussion started by: sbsbg
11 Replies

8. Shell Programming and Scripting

General Q: how to run/schedule a php script from cron jobs maybe via bash from shell?

Status quo is, within a web application, which is coded completely in php (not by me, I dont know php), I have to fill out several fields, and execute it manually by clicking the "go" button in my browser, several times a day. Thats because: The script itself pulls data (textfiles) from a... (3 Replies)
Discussion started by: lowmaster
3 Replies

9. Shell Programming and Scripting

how to make your bash script run on a machine with csh and bash

hi, i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
Discussion started by: npatwardhan
3 Replies

10. Shell Programming and Scripting

different shell csh bash

I'm always having to work in the cshell, but occasionally want to run a command using bash. is that possible? I know I could write a shell script and call bash at the begining with #!/usr/bin/bash and then my command, is there another way? (1 Reply)
Discussion started by: ajp7701
1 Replies
Login or Register to Ask a Question