LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-28-2014, 10:30 AM   #1
shubham.joy
LQ Newbie
 
Registered: Feb 2011
Posts: 6

Rep: Reputation: 0
Run commands from a new terminal in a script


Hi,
My default shell is csh. I have a script that runs correctly on a bash which I want to add to cronjob. How do I make all the commands in the script run on bash.

Currently the cronjob tries to execute the script on csh and reports error.

I tried first first command as bash, and then the rest of the commands. But bash runs and the rest of the commands run on csh.

Following is the script:
Code:
cd /auto/nobackup-bgl-mitg-dev10/shubhaja/
dir_name=latest
#dir_name="$(date +'%d%b').v160.main"
rm -rf $dir_name
mkdir $dir_name
cd $dir_name
git-ws --branch v160.main asr5k/master master    //This works on bash only
cd master
fetch boxer
assemble
 
Old 03-28-2014, 10:40 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,403

Rep: Reputation: Disabled
A script should start with a "shebang" comment specifying the required shell. Use this as the very first line of the script:
Code:
#!/bin/bash
 
Old 03-31-2014, 12:52 AM   #3
shubham.joy
LQ Newbie
 
Registered: Feb 2011
Posts: 6

Original Poster
Rep: Reputation: 0
Still not working. Added the above line.
The script works fine if I execute it from bash by command ./script.txt.

I get errors if I execute it from the default csh shell, even after adding the comment line as the first line.

Quote:
Originally Posted by Ser Olmy View Post
A script should start with a "shebang" comment specifying the required shell. Use this as the very first line of the script:
Code:
#!/bin/bash
 
Old 03-31-2014, 01:44 AM   #4
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,272

Rep: Reputation: 148Reputation: 148
Add this in your beginning of the script.
Quote:
#!/bin/csh
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] make a script that opens a specific terminal and enter commands into that terminal jejuba Linux - General 2 11-10-2013 02:43 PM
[SOLVED] Write a script to open a terminal and run a few commands. jmdennis1987 Linux - General 27 11-18-2010 03:24 PM
making a script that opens terminal and enter commands into that terminal Cinematography Linux - General 8 12-16-2008 11:34 AM
Help to create a script to open a terminal and run commands in it. Brian1 Linux - Software 6 02-07-2005 07:46 PM


All times are GMT -5. The time now is 06:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration