Home > src > matlab > pfs_test_shell.m

pfs_test_shell

PURPOSE ^

PFS_TEST_SHELL run several test to check for common problems with pfstools

SYNOPSIS ^

function pfs_test_shell()

DESCRIPTION ^

PFS_TEST_SHELL run several test to check for common problems with pfstools
matlab interface.

 PFS_TEST_SHELL()

 The function displays test results and instruction what to do if the
 test has failed. 

 Copyright 2009 Rafal Mantiuk

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function pfs_test_shell()
0002 %PFS_TEST_SHELL run several test to check for common problems with pfstools
0003 %matlab interface.
0004 %
0005 % PFS_TEST_SHELL()
0006 %
0007 % The function displays test results and instruction what to do if the
0008 % test has failed.
0009 %
0010 % Copyright 2009 Rafal Mantiuk
0011 
0012 tmp_file = tempname;
0013 
0014 cmd = sprintf( '%secho "OK" | cat >''%s''%s', pfs_shell(), tmp_file, pfs_shell( 1 ) );
0015 
0016 display( '===========================' );
0017 display( ['Test 1: executing: ' cmd ] );
0018 system( cmd );
0019 display( '  If the lines below show a single line "OK", eveything is correct.' );
0020 display( '  If the lines are empty, the shell most probably cannot be executed.' );
0021 display( '  In such a case check error messages either in matlab command window' );
0022 display( '    (Windows) or in the shell window from which you have started matlab (unix).' );
0023 display( '    Then edit pfs_shell.m to fix these problems.' );
0024 display( '  If the lines contain besides "OK" additional lines of text, fix shell startup' );
0025 display( '    files (/etc/profile, ~/.bash_profile and others) so that no messages are' );
0026 display( '    displayed when shell is started' );
0027 display( '---- START ----' );
0028 display_file( tmp_file );
0029 display( '---- END ----' );
0030 
0031 cmd = sprintf( '%swhich pfsin%s', pfs_shell(), pfs_shell( 1 ) );
0032 
0033 display( '===========================' );
0034 display( ['Test 2: executing: ' cmd ] );
0035 [status result] = system( cmd );
0036 if( status == 0 )
0037     display( 'Successful.' );
0038 else
0039     display( 'Shell failed to find pfstools in the PATH. Make sure that the PATH' );
0040     display( '  includes directories with pfstools at shell startup.' );
0041     display( 'Error message: ' );
0042     display( result );
0043 end
0044 
0045 end
0046 
0047 function display_file( file_name )
0048 
0049 fid=fopen( file_name );
0050 while 1
0051     tline = fgetl(fid);
0052     if ~ischar(tline),   break,   end
0053     disp(tline)
0054 end
0055 fclose(fid);
0056 
0057 end

Generated on Tue 03-Mar-2009 13:03:09 by m2html © 2003