html - i want my shell script to generate a file with the output in it -


so basically, instead of writing on , on again html code website building (install page need 1 each app offer download)so made script. want output in file generated so, on console asks should name file (e.g: hi.html) , output in file in specific directory on mac.

# prompt input. app=$1 if [ -z "${app}" ]     read -p "app: " app fi  report=$2 if [ -z "${report}" ]     read -p "report app: " report fi  appicon=$3 if [ -z "${appicon}" ]     read -p "appicon: " appicon fi  plisturl=$4 if [ -z "${plisturl}" ]     read -p "plist url: " plisturl fi  description=$5 if [ -z "${description}" ]     read -p "description: " description fi  version=$6 if [ -z "${version}" ]     read -p "version: " version fi  dev=$7 if [ -z "${dev}" ]     read -p "developer: " dev fi # generate p-list read -r -d '' html << endofhtml ================================================================================  <!doctype html> <html>   <head>     <!-- required meta tags-->     <meta charset="utf-8">     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">     <meta name="apple-mobile-web-app-capable" content="yes">     <meta name="apple-mobile-web-app-status-bar-style" content="black">     <!-- app title -->     <title>my app</title>     <!-- path framework7 ios css theme styles-->     <link rel="stylesheet" href="css/framework7.ios.min.css">     <!-- path framework7 ios related color styles -->     <link rel="stylesheet" href="css/framework7.ios.colors.min.css">     <!-- path custom app styles-->     <link rel="stylesheet" href="css/my-app.css">   </head>   <body>     <!-- status bar overlay full screen mode (phonegap) -->     <div class="statusbar-overlay"></div>      <!-- views -->     <div class="views">       <!-- main view, should have "view-main" class -->       <div class="view view-main">         <!-- top navbar-->         <div class="navbar">   <div class="navbar-inner">     <div class="left"><a href="index.html" class="back link"> <i class="icon icon-back"></i><span>back</span></a></div>     <div class="center sliding">$app</div>     <div class="right"><a href="https://twitter.com/intent/tweet?original_referer=https%3a%2f%2fabout.twitter.com%2fes%2fresources%2fbuttons&ref_src=twsrc%5etfw&related=itsnash0&screen_name=tweakboxapp&text=$report%20does%20not%20work!&tw_p=tweetbutton" class="link external">report app</a></div>   </div> </div>            <!-- pages container, because use fixed-through navbar , toolbar, has additional appropriate classes-->         <div class="pages navbar-through toolbar-through">           <!-- page, "data-page" contains page name -->           <div data-page="index" class="page">             <!-- scrollable page content -->             <div class="page-content">               <!-- content here-->      <img src="appicons/$appicon" class="appinstallicon"/>       <a class="button button-big button-round active installbutton link external" href="itms-services://?action=download-manifest&url=$plisturl"><b>1. install app!</b></a>       <a class="button button-big button-round active installbutton link external" href="prefs:root=general&path=date_and_time"><b>2. change date!</b></a>       <div class="content-block-title">description</div>         <div class="content-block tablet-inset">       <div class="content-block-inner">         <p>$description</p>         <ul>         <li>name: $app</li>         <li>version: $version</li>         <li>developer: $dev</li>         </ul>       </div>     </div>               <!-- content here-->             </div>           </div>         </div>         <!-- bottom toolbar-->              <!-- toolbar links -->      <!-- path framework7 library js-->     <script type="text/javascript" src="js/framework7.min.js"></script>     <!-- path app js-->     <script type="text/javascript" src="js/my-app.js"></script>   </body> </html> ================================================================================  endofhtml  # output. output=$8 if [ -z "${output}" ]     echo "$html" else     echo "$html" >> $output fi 

so dont know how write in bash create file( want name) in specific directory output in it

given want shovel string file. can in 2 different ways.

the first way string:

# here put filename string variable $filename. $filename = "foo.html"  # given have built html string ,  # put variable called $html. # can redirect output of echoing  # our $html variable our $filename variable. echo $html >> $filename 

the second way using argument pass script:

# here $1 contains first argument can pass when running bash script. # example if ran `bash myscript.sh foo.html` $1 contain # string "foo.html". # allow dynamically generate file name without having  # edit script. $filename = $1 echo $html >> $filename 

ie. bash myscript.sh foo.html


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -