Bash tcsh Script runs in terminal but not folder


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash tcsh Script runs in terminal but not folder
# 1  
Old 12-25-2015
Bash tcsh Script runs in terminal but not folder

So, I made a script beginning with #!/bin/bash on gedit.

And I double clicked it to run in terminal and I end up with "The child process exited normally with status 127" and "command not found".

If I run the same script from the terminal as "tcsh (script name)" it runs just fine.

If I copy and past the individual command from my script to the terminal, it runs fine too.

Usually at my work place, double clicking scripts into the terminal works. What do I need to do to be able to run the script with double click on this computer?

Thank you.

p.s. this is my first post.
# 2  
Old 12-25-2015
Hi, welcome to these forums...

From what I gather what you have posted, I'd venture to guess that you have either a csh script or a tcsh script and that your interactive shell is either of those shells.
If that is the case then the shebang #!/bin/bash should be changed to #!/bin/tcsh.
If that is not the case then please post part of your script so we know more....
# 3  
Old 12-25-2015
Quote:
Originally Posted by Scrutinizer
Hi, welcome to these forums...

From what I gather what you have posted, I'd venture to guess that you have either a csh script or a tcsh script and that your interactive shell is either of those shells.
If that is the case then the shebang #!/bin/bash should be changed to #!/bin/tcsh.
If that is not the case then please post part of your script so we know more....
Code:
#!/bin/bash

cd /home/sean/Desktop/rat

3dcalc -a anat.nii -expr a -prefix anat.short -datum short

When I changed the bash to tcsh it worked. But at my workplace computer, this script worked with #!/bin/bash. Why doesn't #!/bin/bash work on my personal laptop?
# 4  
Old 12-25-2015
My guess is that the PATH variable in bash does not contain the directory, in which 3dcalc resides. What happens when you enter this command:

Code:
bash type 3dcalc

If that command reports that the command could not be found, you can try setting the PATH variable explicitly in the script or prepending the 3dcalc command with the absolute path...
# 5  
Old 12-25-2015
ITYM
Code:
bash -c "type 3dcalc"

The following might work as well
Code:
type 3dcalc

Unlke bash, a tcsh script sources .cshrc or .tcshrc at its start.
You better compare with a
Code:
#!/bin/tcsh -f

script.
# 6  
Old 12-25-2015
I feel a little overwhelmed by this guys.

I have little background in computer science but I have to learn how to write scripts. And if another error like this ever comes up I won't know how to handle it.

I'm planning to go through these lessons on youtube " Unix Shell Scripting Tutorial by MrTutorize" to get a better ground on unix, bash, tcsh, paths, scripts.

Is this a good source? Do you have any other sources to recommend me?
# 7  
Old 12-26-2015
The big question is more why use TCSH ?
Most of us use ksh or bash but for compatibility know well the bourn shell basics, and so try to keep the shells easily portable which is not the case with csh/tcsh...( unless you master them also of course...)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Simply Bash Script to Confirm that there are 2 Files in Same Folder

Im looking for 2 Files -> *.WAV and *.wav with find . -name 'unavail.wav' -o -name 'unavail.WAV' I need to list the Folders that contains these 2 Files? Thx in advance (13 Replies)
Discussion started by: valdez
13 Replies

2. Shell Programming and Scripting

[Help] Bash script that runs in the background and checks for mails...

Hello! I have got a homework. The bash script runs in the background and checks the user's mailbox and when the user gets a new mail a popup window appears with some text and information about the sender (from who and when).I have no idea how to start, any help would be appreciated! Thank you:) (1 Reply)
Discussion started by: capo2ndfret
1 Replies

3. Shell Programming and Scripting

How to change Linux Terminal environment variable in a perl or bash script?

Hi, I meet an problem that it cannot change Terminal environment variable in a perl or bash script. This change can only exist and become effective in script lifetime. But I want to make this change take effect in current opened Terminal. In our view, the thought seems to be impossible, As... (9 Replies)
Discussion started by: weichanghe2000
9 Replies

4. UNIX for Dummies Questions & Answers

Bash script that runs permanently

Hello,Geeks How i can run my script permanently. once i run my script it should be working always. like installation. for example if i run one command once in bash script. it must be permanently run in my linux machine.. Thanks in Advance (2 Replies)
Discussion started by: dhanda2601
2 Replies

5. Programming

CGI Perl script to execute bash script- unable to create folder

Hi I have a bash script which takes parameters sh /tmp/gdg.sh -b BASE-NAME -n 1 -s /source/data -p /dest/data/archive -m ARC gdg.sh will scan the /source/data and will move the contents to /dest/data/archive after passing through some filters. Its working superb from bash I have... (0 Replies)
Discussion started by: rakeshkumar
0 Replies

6. Shell Programming and Scripting

Bash script for new file in ftp folder

Hello, I'm trying to make a bash script that send me e-mail if there is any new file in my ftp folder. cat inotify.sh #!/bin/sh /usr/bin/inotifywait -e create \ -mrq /home/mrowcp | while read line; do echo -n "$line " >> /var/log/inotify.log echo `date | cut -d " " -f1-4` >>... (3 Replies)
Discussion started by: mrowcp
3 Replies

7. Shell Programming and Scripting

Need to run a bash script that logs on as a non-root user and runs script as root

So I have a script that runs as a non-root user, lets say the username is 'xymon' . This script needs to log on to a remote system as a non-root user also and call up a bash script that runs another bash script as root. in short: user xymon on system A needs to run a file as root user and have... (2 Replies)
Discussion started by: damang111
2 Replies

8. Shell Programming and Scripting

Run bash script without terminal

How can I make a bash script that keeps on running after I have closed the terminal? Or a script that runs without having the terminal window open? (1 Reply)
Discussion started by: locoroco
1 Replies

9. UNIX for Dummies Questions & Answers

Bash script to rename all files within a folder...

Hi. I don't have any experience with making scripts in bash. I need a simple script to rename all files in a folder to the format file1.avi, file2.avi, file3.avi, and so on..... Please note that the original files have different filenames and different extensions. But they all need to be... (2 Replies)
Discussion started by: dranzer
2 Replies

10. Shell Programming and Scripting

Reading output from terminal back into bash script

How can I get a bash script to wait and read and count $i messages that a running program (drbl clonezilla) sends to the console (terminal) and only then move on to the next line in the script when the count is matched (the next line is the last line of the script and is a reboot)? The script... (0 Replies)
Discussion started by: dp123
0 Replies
Login or Register to Ask a Question