Scripts dont give a consistent output..

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Scripts dont give a consistent output..
# 1  
Old 09-11-2016
Scripts dont give a consistent output..

I have at moment created a setup script that is capable of setting up a workspace for an kaldi enviroment.


The script can be found here setup_base_file

I guess you wouldn't not be able to run it, without having Kaldi installed, but since this question more relates to scripting, than the kaldi framwork, would it not be nessesary to install it.

The problem is when i run the script
Code:
./workspace_setup.sh.

The last command in this script the data directory it has created, sometimes it succeeds other times not, and the sometimes part is what bothers me... why is this the case. I usually test it be deleting all the files it has created by
Code:
rm -rf ../${WORKSPACE}

and then run the script again.

Does something in the script seem to do so?.. It quite annoys me that it works sometime and other times not....

example:

kidi@kidi-ThinkPad-T420s:~/kaldi-trunk/egs/setup_base_files$ ./workspace_setup.s - Pastebin.com

Interesting parts from example:

Code:
Line 144: utils/validate_data_dir.sh: Successfully validated data-directory data/train # Workspace validation sucessfull
Line 146: kidi@kidi-ThinkPad-T420s:~/kaldi-trunk/egs/setup_base_files$ rm -rf ../start/ # Deleting created workspace and all files in it

Line 147: kidi@kidi-ThinkPad-T420s:~/kaldi-trunk/egs/setup_base_files$ ./workspace_setup.sh "start" /home/kidi.. # Creating a new workspace
Line 290: utils/validate_data_dir.sh: file data/train/utt2spk is not in sorted order or has duplicates # Same validation as in line 144  Error encountered.  No change in procedure..


Last edited by kidi; 09-11-2016 at 01:49 PM..
# 2  
Old 09-11-2016
So you want to force delete the parent directory's ${WORKSPACE} .
Code:
 rm -rf ../${WORKSPACE}

What happens IF the variable 'WORKSPACE' is a NULL?
What happens IF said variable is an invalid directory?
What happens IF the said directory does not allow access to delete.
Etc, etc...
What are the error report(s) you get?
This User Gave Thanks to wisecracker For This Post:
# 3  
Old 09-11-2016
Ok.. that part might have been a bit unclear. I don't intent to force delete the parent directory. I just do it, to test whether the scripts provides an consistent output by removing what it has created.

${WORKSPACE} is in this case the name of the workspace = start.

Another script is suppose to validate the the directories within the workspace, as written in the first post. It approves it sometime and other times not.. why am I having this inconsistent output?
# 4  
Old 09-11-2016
I would go though all these files and quote your variables.
# 5  
Old 09-11-2016
Quote:
Originally Posted by kidi
Ok.. that part might have been a bit unclear. I don't intent to force delete the parent directory. I just do it, to test whether the scripts provides an consistent output by removing what it has created.
I did not quote that you are deleting the parent directory bit intend to delete 'WORKSPACE' inside the parent directory. That said I am looking at your "workspace_setup.sh"...
Code:
if [ "$#" -ne "3" ]
then
        echo -e "${RED}USAGE : script.sh WORKSPACE DATASET_PATH UTT_PATH${NC}"
    exit 1
fi
 
 
if [[ $1 = "" ]]
    then
        echo -e "${RED}Missing Workspace name! -  Provide a name!${NC}"
    exit 1
fi
 
 
if [[ $2 = "" ]]
    then
        echo -e "${RED}Missing path to dataset - SPH files${NC}"
    exit 1
fi
 
 
if [[ $3 = "" ]]
    then
        echo -e "${RED}Missing path to Utt!${NC}"
    exit 1
fi

Firstly '$1' can NEVER be NULL if """$2""" and """$3""" exist. They just shift places so that '$2' becomes '$1' and so on.
Code:
cd ../../../

Ouch! Where does this go in the event of an error?
I tried it and it put me into my root directory, if you need the root drawer then why not call it as cd /
If you know what the absolute directory addresses are then why not use them?
Alternatively use the /tmp/your/directory/tree/ to test with thoroughly and change all sources to /full/path/to/your/directory/tree/
You create links to parents of parents too - ouch!
You are also calling Python scripts which I don't intend to check at this point.
Also '$1', '$2', '$3' are script arguments and if any one is wrong or not present do you not have a failsafe to prevent this scenario?
There are other bits and pieces that I, as an amateur, would not do too.

Last edited by wisecracker; 09-11-2016 at 03:48 PM..
# 6  
Old 09-11-2016
Quote:
Originally Posted by wisecracker
I did not quote that you are deleting the parent directory bit intend to delete 'WORKSPACE' inside the parent directory. That said I am looking at your "workspace_setup.sh"...
[code]if [ "$#" -ne "3" ]
then
echo -e "${RED}USAGE : script.sh WORKSPACE DATASET_PATH UTT_PATH${NC}"
exit 1
fi


if [[ $1 = "" ]]
then
echo -e "${RED}Missing Workspace name! - Provide a name!${NC}"
exit 1
fi
[..]/code]
Firstly '$1' can NEVER be NULL if """$2""" and """$3""" exist. They just shift places so that '$2' becomes '$1' and so on.
[..]
Note: here $1 is tested if it is the empty string. $1 CAN be the empty string, while $2 and $3 are not if we call the script like so:
Code:
./script "" value2 value3

or if IFS is set in a certain way..
This User Gave Thanks to Scrutinizer For This Post:
# 7  
Old 09-11-2016
Quote:
Originally Posted by Scrutinizer
Note: here $1 is tested if it is the empty string. $1 CAN be the empty string, while $2 and $3 are not if we call the script like so:
Code:
./script "" value2 value3

or if IFS is set in a certain way..
I was well aware of the double quotes but I was also aware of the fact that this is probably not going to be in the '$1' position...
All the more reason to NOT have things like ../../../
However the 'IFS' reason is new to me and would like to know more so thanks a lot. Off to look...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Nohup not give expected output. Non-stop running process

Hello, I am trying to make a bash script, I tested nohup but it did not help me. My code is: ffmpeg -i $input_url -c:v copy -c:a copy -listen 1 -f mpegts http://localhost:port/live/test When I open it in VLC, it starts feeding my screen and I see bitrate values. When I stop watching it,... (4 Replies)
Discussion started by: baris35
4 Replies

2. Shell Programming and Scripting

How to give full access to output files created by .sh script run via crontab?

Hi Expert, I have a .sh script in my home/new_dir/script.sh This script creates number of output files at home/new_dir/email, home/new_dir/logs dir. I am running this script using crontab (owner root). Now this output files are getting created with rw-r----- 1 root root So if i... (2 Replies)
Discussion started by: Jeet1982
2 Replies

3. Shell Programming and Scripting

Script to give plsql procedure output

##Execute the EDW_MEM_KEY_UPDATE procedure ext_sta=`sqlplus -s ${Connstr} <<eof set heading off; set pagesize 0; set feedback off; set serveroutput on; execute EDW_MEM_KEY_UPDATE ; quit; here` vara="ORA-" var=`echo $ext_sta | grep -c $vara ` Hi All, above is a part of my unix... (7 Replies)
Discussion started by: iamnoone
7 Replies

4. Shell Programming and Scripting

How to give a variable output name in a shell script inside a for loop

Hi all I run my program prog.c in the following way : $ ./prog 1 > output.txt where 1 is a user defined initial value used by the program. But now I want to run it for many a thousand initial values, 1-1000, and store all the outputs in different files. Like $ ./prog 1... (1 Reply)
Discussion started by: alice06
1 Replies

5. Shell Programming and Scripting

give some color to a word on echo output

Hi Supposed this text output: How can I show $HOSTNAME in other color than blank? :-) KSH on AIX (4 Replies)
Discussion started by: iga3725
4 Replies

6. Solaris

metadevice submirrors 0 and 1 not consistent

At a new job, I've inherited a handful of Solaris 10 SunFire V240 servers. I noticed that the metadevices are not consistent, in a way that I've not seen before.... internal mirrored disks: metadevice d60 has c1t0d0s6 as submirror 0 (d61) and c1t1d0s6 as submirror 1 (d62) metadevice... (1 Reply)
Discussion started by: Max Power
1 Replies

7. Shell Programming and Scripting

check for the value of one particular field and give output in a different file

hi i need to check for the value of one particular field : in the output file. the file may contain many such records as below how to ???? *** Throttled with base name + key params! : : -518594328 : les.alarm.LBS12005 : les.alarm.LBS12005 : les : lessrv1 : les : 2328 : 0... (7 Replies)
Discussion started by: aemunathan
7 Replies

8. Shell Programming and Scripting

Compare 2 files and give uniq output

Hi , Just to find out a way to compare these 2 files and give unique output. For eg: 1.txt contains 1 2 3 4 5 6 -------------------------------------- 2.txt contains 1 2 6 8 (1 Reply)
Discussion started by: rauphelhunter
1 Replies

9. Shell Programming and Scripting

Routine doesn't give output when executed in crontab

I have a script running in the crontab that gets data from a database every hour. Now I would like to execute a fortran routine to process the data in some way, after getting it and saving it locally. I have added the following commands to my script: set convert =... (1 Reply)
Discussion started by: SharkM
1 Replies
Login or Register to Ask a Question