Debugging a script with noexec


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Debugging a script with noexec
# 1  
Old 01-13-2012
Debugging a script with noexec

Newbie question. I cannot get "set -n" or "set -noexec on" to work on Linux or AIX! According to the man page and what I read online, it should inform me of syntax errors without executing commands in your script.

So, can someone PLEASE explain why this does not work?

======================================
# WHAT I SHOULD SEE

rochatk:/tmp # cat t1
#set -n

echo test
ech test1

rochatk:/tmp # ./t1
test
./t1: line 4: ech: command not found



# REMOVE COMMENT FROM SET COMMAND

rochatk:/tmp # vi t1
rochatk:/tmp # cat t1
set -n

echo test
ech test1

rochatk:/tmp # ./t1
rochatk:/tmp #


======================================

Why don't I see the error after "set -n" is enabled?
Thank you for your help!
# 2  
Old 01-13-2012
There's nothing wrong with the syntax, though. If 'ech' actually existed on your system, it would be run.

So syntax checking alone won't catch this error.
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 01-13-2012
I see, you are correct. I tried a bad syntax example and it worked as expected
Code:
if [ 3 -eq 4 ];
  echo wrong
fi

DOES yield a syntax error.

So, this isn't as useful as I hoped if it doesn't catch ALL the errors, but thank you for your help in understanding why.

Last edited by Franklin52; 01-14-2012 at 09:25 AM.. Reason: Please use code tags for data and code samples, thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Noexec on /home

Hi all, I read in some documents that it is advised to use the mount option noexec also on /home. I can live with a nosuid but since I am writing scripts in /home and also execute them for testing etc., it is very annoying if I would be forced to copy the scripts all the time to /tmp for... (5 Replies)
Discussion started by: zaxxon
5 Replies

2. Shell Programming and Scripting

Shell script debugging

hi all only the weirdest thing happened with me just now. I was debugging a shell script and I found that a step that was supposed to execute later was getting executed prior to another step for no reason. You know any ? i mean have a look at the following command- here it tries to grep... (7 Replies)
Discussion started by: leghorn
7 Replies

3. Shell Programming and Scripting

Having trouble with My Bash Script, need Help debugging

Hello Friends I am having trouble with my script below. I will describe the problems below the code box. I am hoping that some of the experts here can help me. #!/bin/bash #========================================================================================================= # Rsync File... (8 Replies)
Discussion started by: jdavis_33
8 Replies

4. Red Hat

“noexec” and “nosuid”

I would like mimic "noexec” and “nosuid” on /tmp security when its a seperate file system BUT I would like to hang /tmp directly off of / "root". Any suggestions would be helpful. (1 Reply)
Discussion started by: trscam
1 Replies

5. Shell Programming and Scripting

debugging the shell script with out actually running

Hello, Some one asked me in the inteview.... The question is, How do we debug the schell script before even running..... Interviewer told me one clue... There is SET command to accomplish this... Can any one tell me what kind of set commands.... Thanks. (2 Replies)
Discussion started by: govindts
2 Replies

6. Shell Programming and Scripting

script debugging

is there any way you can add a breakpoint in a script so you can stop on it? i have used -xv in my shebang but the script just runs and i want it to stop at a specific point in the script. appreciate any help. (1 Reply)
Discussion started by: npatwardhan
1 Replies

7. Shell Programming and Scripting

debugging a script??

Hi all, Am working on a script to understand the flow control of it.. Since i am from a C background i looking out for an easy way to analyze the script as it runs .. In C/C++ we have F7 that starts execution from main() and proceeds accordingly.. I was wondering if there is a same approach... (2 Replies)
Discussion started by: wrapster
2 Replies

8. Shell Programming and Scripting

Nee help debugging script..plz

I am having problems w/this script. Menu is not comming up to prompt me. I've worked on it for days and still cannot see the problem. Anyone can help, I would appreciate it. Possible problems with syntax and function calls. Thks... TMP=$tapemgr/rpts/tmp # TAPE MANAGER MAIN MENU while : do... (8 Replies)
Discussion started by: gzs553
8 Replies

9. Shell Programming and Scripting

FTP script debugging

Hello all, I am trying to run a script and have not had much success running it...ne help debugging it will be appreciated..The ftp script alone works but not within the while loop. below is the script #!/usr/bin/ksh destination_server=servename destination_user_id=un... (1 Reply)
Discussion started by: alfredo123
1 Replies

10. Shell Programming and Scripting

HP-UX Debugging Shell script

Hi, I was using AIX - ksh shell , and inorder to debug shell script I used set -vx to echo all the commands which are being executed. Can anybody tell me the corresponding method in HP-UX - in tcsh shell. Regards Shihab (1 Reply)
Discussion started by: shihabvk
1 Replies
Login or Register to Ask a Question