Assigning Variables

Displaying Variables

#!/bin/shecho$length# 80echo length=$length# length=80echo this is $title# this is Greetings from Spaceecho${chapter}5 # chap5 - to display with no space between variable and other parts of string

Special Variables

#!/bin/sh$?# exit status of the last command$$# process number of the current shell$!# process number of the last background command$0# filename of the current script$# # number of arguments$n# arguments (n = 1, 2, ...)$@# equivalent of $1 $2 ... $n$*# same as $@

That is: find all subdirectories of current directory; for each subdirectory, find all files, and print file count and path. Finally it sorts the result to show folders with most files on top
Note that the first entry is the folder itself. Also this script omits soft links and does not count sub-folders as files.

Tableau Public
Requires tool download (Windows only) and creation of the account, and allows to publish charts online, as well as store them as PDF or image. Very powerful set of graphs, and ability to create a dashboard. Allows to load data set from many different sources.

Infogr.am
Requires to create an account (Facebook / Twitter login can be used). Good selection of charts (data can be imported from Excel spreadsheets), which can also be wrapped into a few themes (and can contain graphical text, images and charts). Simple intuitive UI. No graphs or trees, however, and no option to export (can only publish online).

Easel.ly
Requires to create an account. You can choose a theme from many different templates, or create a new one from scratch. Shapes are a central piece of the design, and can create many different forms: from tree and graph to a diagram. Presentations can also contain images and graphic text, but no ability to create charts based on data. Can be published online or exported as JPG.

Many Eyes
IBM site, based on Cognos, that allows to visualize data sets. Site design, and user experience in general are quite outdated, clumsy and slow (Java applets are used to render charts). However has a decent set of chart types, diagrams, and maps. Result can be published online or exported as PNG.

Charts Bin
Requires to create an account. Allows to upload and visualize location-based data. Has a few options, and user interface is not very smooth. However what’s valuable is the ability to create interactive maps with data, allows to publish or download it as PNG.

For script in the previous post, I needed a tool that would convert PowerShell script to HTML format. Surprisingly numerous online tools somehow completely ignored PowerShell, so I found PowerShell scripts that would do the job: PowerShell Syntax Highlighting by Lee Holmes, an extended version by Helge Klein, and different implementation, which will only work on PowerShell 2.0 by Jeff Hillman.

# Those constants normally do not change[string]$LOGIN_URL=“http://{0}/login.jsp?os_username={1}&os_password={2}&os_destination=/secure/”[string]$CREATE_URL=“http://{0}/secure/CreateIssueDetails.jspa?pid={1}&{2}&Create=Create&atl_token={3}”[string]$TOKEN_PREFIX=‘<meta id=”atlassian-token” name=”atlassian-token” content=”‘[string]$TOKEN_SUFFIX=‘”>’

function loginToJira($server,$user,$pwd) {

[string]$postUrl=$url-f$user,$pwd

[System.Net.WebRequest] $webRequest= [System.Net.WebRequest]::Create($postUrl)$webRequest.CookieContainer =New-object System.Net.CookieContainer
[System.Net.WebResponse] $webResponse=$webRequest.getResponse()# TO DO: Response can be verified here# One of the ways to check if request was successful is to read $webResponse.StatusDescription, e.g.Write-Host“status = “$webResponse.StatusDescription;

$resStream=$webResponse.GetResponseStream()
[System.IO.StreamReader]$streamReader=New-Object System.IO.StreamReader -argumentList $resStream$res=$streamReader.ReadToEnd()# TO DO: Here it can be verified if the issue was posted successully, by looking into $res# If issue is not posted, Jira will return HTML similar to the page seeing by the user who tried to post issue with missing / problematic fields
}

In the Data Validation dialog, Settings tab, set:Allow: ListSource: [range, that represents list of values in the list, e.g. “=A1:A5“]

Click OK

In many cases, however, it’s more convenient to store list contents on separate sheet. But if you try to specify Source from a different spreadsheet (e.g. “=Sheet2!A1:A5“), Excel will throw an error: “The formula you typed contains an error. <…>“. Apparently Excel does not allow range from a different spreadsheet. But there’s a nice workaround, which I digged out of internet long time ago, and can’t remember the source. What you need to do, is to create a named range, and use it instead of the cell range.

Creating a named range:

Go to a sheet where list is located, and select all list items.

Right click on selected cells and choose Name a Range… or select Formulas > Define Name

Specify Name for the range (e.g. ‘MyList‘) and verify that Refers to range is correct.

Click OK.

Now you can use a named range you just created in the Data Validation:

Select cells you want to attach list to

Select Data > Data Validation

In the Data Validation dialog, Settings tab, set:Allow: List
Source: [equal sign and the name of the range you just created “=MyList“]