Test shell script (PROBLEM)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Test shell script (PROBLEM)
# 1  
Old 04-16-2013
Test shell script (PROBLEM)

Dears ,

kindly I wanna do test for one KSH script to know how is it working , the problem that I'm facing is whenever put "sh -x ./my_script.sh"
the output seems very long & although I tried to to redirect it to files as it shown , but it failed Smilie :-

sh -x ./my_script.sh > output.txt
or
sh -x ./my_script.sh | tee output.txt
Smilie
I'm sure there is a way to redirect the output from "test shell script" to be able to read and analyze the error that I did in every line in that shell , please do support to show me how can overcome such , as far as I know test the script is really a good step to be professional in programming world .

thanks .
# 2  
Old 04-16-2013
The trace information will come out to standard error (file descriptor 2) rather than standard output.

You could try:-
Code:
sh -x ./my_script.sh > output.txt 2>&1

or
Code:
sh -x ./my_script.sh 2>&1 | tee output.txt



I hope that this helps, but let us know if not.

Robin
Liverpool/Blackburn
UK
This User Gave Thanks to rbatte1 For This Post:
# 3  
Old 04-17-2013
thanks

thanks a lot , I was guessing that testing any script is not considered as standard error that is why I'm not thinking to redirect the output this way , I can see what I was looking for , thanks for prompt response Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Shell Script to test telnet connection using port

Hello, I need to test telnet connections using port number for few hosts. Could you please help me? Thanks !! (1 Reply)
Discussion started by: skhichi
1 Replies

2. UNIX for Dummies Questions & Answers

Problem with test syntax in script

Hi guys here i'm again with more question The code below try to find an user and write everything about him if exist, so my problem appear on line of test, where the program test if the user has secondary groups related. The rest it's clear # usugrup.sh lista todas las caracteristicas de un... (3 Replies)
Discussion started by: Newer
3 Replies

3. UNIX for Dummies Questions & Answers

Test: argument expected error in shell script

Hi, I am trying to write a small script that validates if there exist files that start with a pattern in a given directory. Below is the piece of my script: #!/usr/bin/ksh BTFDIR=/opt/ships/temp if then echo 'found' else echo 'not found' fi When I run this... (2 Replies)
Discussion started by: snvniranjanrao
2 Replies

4. Shell Programming and Scripting

Help with connectivity test using shell script

I want to test connectivity between different servers with my server using information as IP and port only. I have Name,IP List and port in one file. Please help how i can test connectivity is successful or not? File format will be: Name1,127.0.0.1,80 Name2,127.0.0.2,8080 Output could be ... (1 Reply)
Discussion started by: poweroflinux
1 Replies

5. Shell Programming and Scripting

-a test in shell script

I need clarification in -a test. If say, in test -a left expression is not present but the right expression is present, do the shell will consider the left expression true and evaluate the right expression? For example: if ] then rm -f ${file} fi Is this test condition... (7 Replies)
Discussion started by: jatanig
7 Replies

6. UNIX for Dummies Questions & Answers

How do i tell my bash shell script to test the output of a command against something

How do i tell my bash shell script to test the output of the command i'm using?? I want this script to look for lines not equal to 1 then let me know.. $ cat blah ; echo ---- ; cat blah.sh 1 fe 1 fi 1 fo 0 fum 1 blahda 1 blah 0 blahh 1 bla 1 bl 1 blahhh ---- #!/bin/bash while... (1 Reply)
Discussion started by: phpfreak
1 Replies

7. Shell Programming and Scripting

test script to identify SHELL

I am new to BASH and writing a small script to identify the SHELL . #!/bin/bash BASH='/bin/bash' KSH='/bin/ksh' if then echo "it's Bash" else echo "it's not Bash" fi $ bash -x a.sh + BASH=/bin/bash + KSH=/bin/ksh + '' a.sh: line 4: where am I missing . PLease advice . (10 Replies)
Discussion started by: talashil
10 Replies

8. Shell Programming and Scripting

Test for shell interpreter at beginning of script

What would be the best way or method to determine or test for the shell interpreter at the beginning of a script in the event one shell is not available? If I use the following: #!/bin/bash and /bin/bash is not available, then use I'd like to use /bin/ksh if it is available. #!/bin/ksh (8 Replies)
Discussion started by: nck
8 Replies

9. Shell Programming and Scripting

Test File Reading & Validation using Shell script

Please help develop script for below requirement -------Sample file------------------------------- HSVSHOSTRECON 20090115011817BP DARMAR60064966247003504720000000000000000000066626000000000000133000003D003463001332 ... (14 Replies)
Discussion started by: niraj_bhatt
14 Replies

10. Shell Programming and Scripting

need help with test condition in shell script

I'm new to scripting and I need help with a bourn shell script. What i'm trying to do is a test condition where "if the time is within 2 hours, it's true" and so on. The time is in the following format DATE=`/bin/date +"%Y%m%d%H%S"` for example, 20060907152000. So, what the script first... (9 Replies)
Discussion started by: pieman8080
9 Replies
Login or Register to Ask a Question