Changeset 1487 for palm


Ignore:
Timestamp:
Oct 25, 2014 2:36:28 PM (10 years ago)
Author:
raasch
Message:

bash compatibility adjustments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • palm/trunk/SCRIPTS/mbuild

    r1469 r1487  
    1 #!/bin/ksh
     1#!/bin/bash
    22
    33# mbuild - script for compiling the PALM code and its utility programs
     
    2222# Current revisions:
    2323# ------------------
    24 #
     24# bash compatibility adjustments: output formatting with printf instead
     25# of "typeset -L/-R", print replaced by echo
    2526#
    2627# Former revisions:
     
    117118 typeset -i  ih ihost=0
    118119
    119  typeset  -R30 calltime
    120  typeset  -L20 column1
    121  typeset  -L50 column2
    122  typeset  -L70 column3
    123  typeset  -L40 version="MBUILD  2.1  Rev$Rev$"
     120 calltime=""
     121 column1=""
     122 column2=""
     123 column3=""
     124 version="MBUILD  2.1  Rev$Rev$"
    124125
    125126    # ERROR HANDLING
     
    174175    # DETERMINE THE LOCAL HOST
    175176 local_host_real_name=$(hostname)
    176 # local_address=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{print $2}')
     177 local_address=$(nslookup `hostname` 2>&1 | grep "Address:" | tail -1 | awk '{echo $2}')
    177178
    178179
     
    357358 printf "\n"
    358359 printf "#------------------------------------------------------------------------# \n"
    359  printf "| $version$calltime | \n"
     360 printf "| %-40s%30s | \n" "$version" "$calltime"
    360361 printf "|                                                                        | \n"
    361  column1="called on:"; column2=$local_host_real_name
    362  printf "| $column1$column2 | \n"
    363  column1="local username:"; column2=$local_username
    364  printf "| $column1$column2 | \n"
    365  column1="local IP-address:"; column2=$local_address
    366  printf "| $column1$column2 | \n"
    367  column1="config file:"; column2=$config_file
    368  printf "| $column1$column2 | \n"
    369  column1="makefile:"; column2=$makefile
    370  printf "| $column1$column2 | \n"
    371  column1="local source path:"; column2=$local_source_path
    372  printf "| $column1$column2 | \n"
     362 printf "| %-20s%-50s | \n" "called on:" "$local_host_real_name"
     363 printf "| %-20s%-50s | \n" "local username:" "$local_username"
     364 printf "| %-20s%-50s | \n" "local IP-address:" "$local_address"
     365 column2=$(echo $config_file | cut -c1-50 )
     366 printf "| %-20s%-50s | \n" "config file:" "$column2"
     367 line=$(echo "$config_file" | cut -c51-)
     368 while [[ "$line" != "" ]]
     369 do
     370    column1=""
     371    column2=$(echo $line | cut -c1-50 )
     372    printf "| %-20s%-50s | \n" "$column1" "$column2"
     373    line=$(echo "$line" | cut -c51-)
     374 done
     375 column2=$(echo $makefile | cut -c1-50 )
     376 printf "| %-20s%-50s | \n" "makefile:" "$column2"
     377 line=$(echo "$makefile" | cut -c51-)
     378 while [[ "$line" != "" ]]
     379 do
     380    column1=""
     381    column2=$(echo $line | cut -c1-50 )
     382    printf "| %-20s%-50s | \n" "$column1" "$column2"
     383    line=$(echo "$line" | cut -c51-)
     384 done
     385 column2=$(echo $local_source_path | cut -c1-50 )
     386 printf "| %-20s%-50s | \n" "local source path:" "$column2"
     387 line=$(echo "$local_source_path" | cut -c51-)
     388 while [[ "$line" != "" ]]
     389 do
     390    column1=""
     391    column2=$(echo $line | cut -c1-50 )
     392    printf "| %-20s%-50s | \n" "$column1" "$column2"
     393    line=$(echo "$line" | cut -c51-)
     394 done
    373395 printf "#------------------------------------------------------------------------# \n"
    374 
    375 # printf "|                                                                        | \n"
    376396
    377397
     
    943963    if [[ $remote_host = $local_host ]]
    944964    then
    945        column1="remote_host:"; column2="$remote_host (= local host!)"
     965       column2="$remote_host (= local host!)"
    946966    else
    947        column1="remote_host:"; column2=$remote_host
    948     fi
    949     printf "| $column1$column2 | \n"
     967       column2=$remote_host
     968    fi
     969    printf "| %-20s%-50s | \n" "remote_host:" "$column2"
    950970    printf "|                                                                        | \n"
    951     column1="conditions:"; column2="$condition1 $condition2"
    952     printf "| $column1$column2 | \n"
    953     column1="make depository:"; column2=$remote_md
    954     printf "| $column1$column2 | \n"
     971    printf "| %-20s%-50s | \n" "conditions:" "$condition1 $condition2"
     972    column2=$(echo "$remote_md" | cut -c1-50 )
     973    printf "| %-20s%-50s | \n" "make depository:" "$column2"
    955974    line=$(echo "$remote_md" | cut -c51-)
    956975    while [[ "$line" != "" ]]
    957976    do
    958977       column1=""
    959        column2=$line
    960        printf "| $column1$column2 | \n"
     978       column2=$(echo "$line" | cut -c1-50 )
     979       printf "| %-20s%-50s | \n" "$column1" "$column2"
    961980       line=$(echo "$line" | cut -c51-)
    962981    done
    963982    if [[ $compile_utility_programs = true ]]
    964983    then
    965        column1="utility directory:"; column2=$remote_ud
     984       column2=$(echo "$remote_ud" | cut -c1-50 )
    966985       printf "| $column1$column2 | \n"
    967     fi
    968     column1="username:"; column2=$remote_username
    969     printf "| $column1$column2 | \n"
    970     column1="address:"; column2=$remote_address
    971     printf "| $column1$column2 | \n"
    972     column1="compiler:"; column2=$compiler_name
    973     printf "| $column1$column2 | \n"
     986       printf "| %-20s%-50s | \n" "utility directory:" "$column2"
     987       line=$(echo "$remote_ud" | cut -c51-)
     988       while [[ "$line" != "" ]]
     989       do
     990          column1=""
     991          column2=$(echo "$line" | cut -c1-50 )
     992          printf "| %-20s%-50s | \n" "$column1" "$column2"
     993          line=$(echo "$line" | cut -c51-)
     994       done
     995    fi
     996    printf "| %-20s%-50s | \n" "username:" "$remote_username"
     997    printf "| %-20s%-50s | \n" "address:" "$remote_address"
     998    printf "| %-20s%-50s | \n" "compiler:" "$compiler_name"
    974999    if [[ $compile_utility_programs = true ]]
    9751000    then
    976        column1="serial compiler:"; column2=$compiler_name_ser
    977        printf "| $column1$column2 | \n"
     1001       printf "| %-20s%-50s | \n" "serial compiler:" "$compiler_name_ser"
    9781002    fi
    9791003    if [[ "$make_options" != "" ]]
    9801004    then
    981        column1="make options:"; column2=$make_options
    982        printf "| $column1$column2 | \n"
    983     fi
    984     column1="cpp options:"; column2=$cpp_options
    985     printf "| $column1$column2 | \n"
     1005       printf "| %-20s%-50s | \n" "make options:" "$make_options"
     1006    fi
     1007    column2=$(echo $cpp_options | cut -c1-50 )
     1008    printf "| %-20s%-50s | \n" "cpp options:" "$column2"
    9861009    line=$(echo "$cpp_options" | cut -c51-)
    9871010    while [[ "$line" != "" ]]
    9881011    do
    9891012       column1=""
    990        column2=$line
    991        printf "| $column1$column2 | \n"
     1013       column2=$(echo $line | cut -c1-50 )
     1014       printf "| %-20s%-50s | \n" "$column1" "$column2"
    9921015       line=$(echo "$line" | cut -c51-)
    9931016    done
    994     column1="compiler options:"; column2=$compiler_options
    995     printf "| $column1$column2 | \n"
     1017    column2=$(echo $compiler_options | cut -c1-50 )
     1018    printf "| %-20s%-50s | \n" "compiler options:" "$column2"
    9961019    line=$(echo "$compiler_options" | cut -c51-)
    9971020    while [[ "$line" != "" ]]
    9981021    do
    9991022       column1=""
    1000        column2=$line
    1001        printf "| $column1$column2 | \n"
     1023       column2=$(echo $line | cut -c1-50 )
     1024       printf "| %-20s%-50s | \n" "$column1" "$column2"
    10021025       line=$(echo "$line" | cut -c51-)
    10031026    done
    1004     column1="loader options:"; column2=$loader_options
    1005     printf "| $column1$column2 | \n"
     1027    column2=$(echo $loader_options | cut -c1-50 )
     1028    printf "| %-20s%-50s | \n" "loader options:" "$column2"
    10061029    line=$(echo "$loader_options" | cut -c51-)
    10071030    while [[ "$line" != "" ]]
    10081031    do
    10091032       column1=""
    1010        column2=$line
    1011        printf "| $column1$column2 | \n"
     1033       column2=$(echo $line | cut -c1-50 )
     1034       printf "| %-20s%-50s | \n" "$column1" "$column2"
    10121035       line=$(echo "$line" | cut -c51-)
    10131036    done
    10141037    if [[ $modules != "" ]]
    10151038    then
    1016        column1="modules to be load:"; column2=$modules
    1017        printf "| $column1$column2 | \n"
     1039       column2=$(echo $modules | cut -c1-50 )
     1040       printf "| %-20s%-50s | \n" "modules to be load:" "$column2"
    10181041       line=$(echo "$modules" | cut -c51-)
    10191042       while [[ "$line" != "" ]]
    10201043       do
    10211044          column1=""
    1022           column2=$line
    1023           printf "| $column1$column2 | \n"
     1045          column2=$(echo $line | cut -c1-50 )
     1046          printf "| %-20s%-50s | \n" "$column1" "$column2"
    10241047          line=$(echo "$line" | cut -c51-)
    10251048       done
     
    10651088          else
    10661089                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
    1067              print "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"  |  ssh ${remote_username}@${remote_address}  2>&1
     1090             echo "[[ ! -d ${remote_md} ]]  &&  (echo \"  *** ${remote_md} will be created\"; mkdir -p  ${remote_md})"  |  ssh ${remote_username}@${remote_address}  2>&1
    10681091          fi
    10691092
     
    10791102          else
    10801103                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
    1081              print "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"  |  ssh  ${remote_username}@${remote_address}  2>&1
     1104             echo "cd ${remote_md}; [[ -f ${mainprog}_current_version.tar ]]  &&  tar -xf  ${mainprog}_current_version.tar"  |  ssh  ${remote_username}@${remote_address}  2>&1
    10821105          fi
    10831106
     
    10901113          else
    10911114                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
    1092              print  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"  |  ssh  ${remote_username}@${remote_address}  2>&1
     1115             echo  "cd ${remote_md}; tar -xf  ${mainprog}_sources.tar"  |  ssh  ${remote_username}@${remote_address}  2>&1
    10931116          fi
    10941117
     
    11301153          then
    11311154
    1132              print "$init_cmds $module_calls export OBJECT_MODE=64; cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll
     1155             echo "$init_cmds $module_calls export OBJECT_MODE=64; cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll
    11331156
    11341157          elif [[ $remote_host = lctit ]]
     
    11381161             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
    11391162             do
    1140                 print "cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll
     1163                echo "cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll
    11411164             done
    11421165
     
    11481171          else
    11491172
    1150              print "$init_cmds $module_calls cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll
     1173             echo "$init_cmds $module_calls cd ${remote_md}; echo $make_call_string > LAST_MAKE_CALL; chmod u+x LAST_MAKE_CALL; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll
    11511174
    11521175          fi
     
    11841207          else
    11851208                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
    1186              print  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"  |  ssh  ${remote_username}@${remote_address}  2>&1
     1209             echo  "cd ${remote_md}; chmod u+w *; tar -cf  ${mainprog}_current_version.tar  ${mainprog}  *.f90 *.o *.mod"  |  ssh  ${remote_username}@${remote_address}  2>&1
    11871210          fi
    11881211
     
    12041227          else
    12051228                # USING PIPE, BECAUSE TIT ALLOWS SSH TO EXECUTE ONLY SOME SELECTED COMMANDS
    1206              print "[[ ! -d ${remote_ud} ]]  &&  (echo \"  *** ${remote_ud} will be created\"; mkdir -p  ${remote_ud}); [[ ! -d ${remote_ud}/../SCRIPTS ]]  &&  (echo \"  *** ${remote_ud}/../SCRIPTS will be created\"; mkdir -p  ${remote_ud}/../SCRIPTS)"  |  ssh ${remote_username}@${remote_address}  2>&1
     1229             echo "[[ ! -d ${remote_ud} ]]  &&  (echo \"  *** ${remote_ud} will be created\"; mkdir -p  ${remote_ud}); [[ ! -d ${remote_ud}/../SCRIPTS ]]  &&  (echo \"  *** ${remote_ud}/../SCRIPTS will be created\"; mkdir -p  ${remote_ud}/../SCRIPTS)"  |  ssh ${remote_username}@${remote_address}  2>&1
    12071230          fi
    12081231
     
    12541277          then
    12551278
    1256              print "$init_cmds $module_calls export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address}
     1279             echo "$init_cmds $module_calls export OBJECT_MODE=64; cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address}
    12571280
    12581281          elif [[ $remote_host = lctit ]]
     
    12621285             while [[ $(cat ${remote_host}_last_make_protokoll | grep -c "Forwarding to N1GE") = 0 ]]
    12631286             do
    1264                 print "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll
     1287                echo "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll
    12651288             done
    12661289
     
    12721295          else
    12731296
    1274              print "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll
     1297             echo "$init_cmds $module_calls cd ${remote_ud}; $make_call_string; [[ \$? != 0 ]] && echo MAKE_ERROR" | ssh  ${remote_username}@${remote_address} 2>&1 | tee ${remote_host}_last_make_protokoll
    12751298
    12761299          fi
Note: See TracChangeset for help on using the changeset viewer.