<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: jsguru</title>
    <description>The latest articles on DEV Community by jsguru (@jsgurugit).</description>
    <link>https://dev.to/jsgurugit</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F324519%2Faeae0f14-5939-4b00-9e64-7a2e8f857b48.jpeg</url>
      <title>DEV Community: jsguru</title>
      <link>https://dev.to/jsgurugit</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jsgurugit"/>
    <language>en</language>
    <item>
      <title>List users in SQL Server database</title>
      <dc:creator>jsguru</dc:creator>
      <pubDate>Sun, 23 Feb 2020 19:12:35 +0000</pubDate>
      <link>https://dev.to/jsgurugit/list-users-in-sql-server-database-1k20</link>
      <guid>https://dev.to/jsgurugit/list-users-in-sql-server-database-1k20</guid>
      <description>&lt;p&gt;The image below shows how. (on Microsoft SQL Server Management Studio).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jthZy3R2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zbc8x2y354wetu2oj788.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jthZy3R2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zbc8x2y354wetu2oj788.jpg" alt="List users in sql server database on SSMS"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Query&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="n"&gt;use&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;database_name&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;create_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;modify_date&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;type_desc&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
       &lt;span class="n"&gt;authentication_type_desc&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;authentication_type&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;database_principals&lt;/span&gt;
&lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="k"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'A'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'G'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'R'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'X'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;and&lt;/span&gt; &lt;span class="n"&gt;sid&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="k"&gt;not&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;
      &lt;span class="k"&gt;and&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s1"&gt;'guest'&lt;/span&gt;
&lt;span class="k"&gt;order&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>sqlserver</category>
    </item>
    <item>
      <title>I could not access newly created web application in SharePoint Central Administration.</title>
      <dc:creator>jsguru</dc:creator>
      <pubDate>Fri, 21 Feb 2020 19:51:21 +0000</pubDate>
      <link>https://dev.to/jsgurugit/i-could-not-access-newly-created-web-application-in-sharepoint-central-administration-onp</link>
      <guid>https://dev.to/jsgurugit/i-could-not-access-newly-created-web-application-in-sharepoint-central-administration-onp</guid>
      <description>&lt;h3&gt;
  
  
  &lt;strong&gt;"I could not access newly created web application in SharePoint Central Administration."&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;It was the problem that bothered me today.&lt;/p&gt;

&lt;p&gt;After strenuous efforts, I resolved it.&lt;/p&gt;

&lt;p&gt;I installed &lt;strong&gt;SharePoint Server 2019&lt;/strong&gt; on &lt;strong&gt;Windows Server 2019&lt;/strong&gt; in &lt;strong&gt;VMware Workstation 15 Pro&lt;/strong&gt;.&lt;br&gt;
Then I created a new web application using default settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Z90OBbSZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xg19k5l2fulnugsoqsqy.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Z90OBbSZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/xg19k5l2fulnugsoqsqy.jpg" alt="create new web application"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Web application &lt;code&gt;jsguru.group.com:29457&lt;/code&gt; was created. See screenshot below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NHkO7bCK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/txq3zgw1q4tabfl0e4du.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NHkO7bCK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/txq3zgw1q4tabfl0e4du.jpg" alt="jsguru.group.com"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So far so good.&lt;br&gt;
But when I tried to access the web application in VM machine I had worked on, I could not.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EIGCpWIA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vebd5bjgwtkfodl8ulbx.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EIGCpWIA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vebd5bjgwtkfodl8ulbx.jpg" alt="connection failure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let me show you how I resolved it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1.&lt;/strong&gt; Add the web application name (here &lt;code&gt;jsguru.group.com&lt;/code&gt;) to the string value of &lt;code&gt;BackConnectionHostNames&lt;/code&gt; under &lt;br&gt;
 windows registry &lt;code&gt;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0&lt;/code&gt;.&lt;br&gt;
If there is no entry &lt;code&gt;BackConnectionHostNames&lt;/code&gt;, you have to create it as multi-string value.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--c3OMV_Z6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mtnvi4s5yc9mgdazl0l5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--c3OMV_Z6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mtnvi4s5yc9mgdazl0l5.jpg" alt="BackConnectionHostNames"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alternatively, create DWORD-value entry &lt;code&gt;DisableLoopbackCheck&lt;/code&gt; with value 1 under &lt;code&gt;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa&lt;/code&gt;.(This is not recommended)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2.&lt;/strong&gt; Add the IP address and host name of the web application to the bottom of the hosts file. The hosts file path is &lt;code&gt;C:\Windows\System32\drivers\etc&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9QJ-oSoi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/79t6ahhwtmp5ooqmpk0f.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9QJ-oSoi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/79t6ahhwtmp5ooqmpk0f.jpg" alt="hosts"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thus I could get access to the web application.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZD-RzpKa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/j551gd9cj73f902mqt79.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZD-RzpKa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/j551gd9cj73f902mqt79.jpg" alt="success"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope this helps someone who is trying to do the same thing like me.&lt;/p&gt;

</description>
      <category>sharepoint</category>
      <category>windowsserver</category>
      <category>vmware</category>
    </item>
    <item>
      <title>How to Setup Python Virtual Environment for Python3 on Ubuntu 19.10</title>
      <dc:creator>jsguru</dc:creator>
      <pubDate>Mon, 03 Feb 2020 08:45:14 +0000</pubDate>
      <link>https://dev.to/jsgurugit/how-to-setup-python-virtual-environment-for-python3-on-ubuntu-19-10-dkp</link>
      <guid>https://dev.to/jsgurugit/how-to-setup-python-virtual-environment-for-python3-on-ubuntu-19-10-dkp</guid>
      <description>&lt;p&gt;If your OS is Ubuntu 19.10, you don't need to install python3 separately.&lt;br&gt;
Because Ubuntu comes with Python3.&lt;br&gt;
You can check it by typing:&lt;br&gt;
&lt;code&gt;$ python3 --version&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jsguru@ubuntu:~$ python3 --version
Python 3.7.5
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then, the first step is to install pip for Python3&lt;br&gt;
&lt;code&gt;$ sudo apt-get install python3-pip&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Working on a python project in an isolated python environment is recommended so that python modules and packages don't meddle with that of other projects or even that of the operating system. Thus, a virtual environment is needed eminently.&lt;/p&gt;

&lt;p&gt;We can achieve it with &lt;strong&gt;&lt;code&gt;virtualenv&lt;/code&gt;&lt;/strong&gt; or &lt;strong&gt;&lt;code&gt;virtualenvwrapper&lt;/code&gt;&lt;/strong&gt;.&lt;br&gt;
&lt;strong&gt;&lt;code&gt;virtualenvwrapper&lt;/code&gt;&lt;/strong&gt; is better choice than &lt;strong&gt;&lt;code&gt;virtualenv&lt;/code&gt;&lt;/strong&gt;.&lt;br&gt;
Creating and deleting virtual environments is easy with &lt;strong&gt;&lt;code&gt;virtualenvwrapper&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;For installation it run:&lt;br&gt;
&lt;code&gt;$ sudo pip3 install virtualenvwrapper&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And&lt;br&gt;
&lt;code&gt;$ mkdir ~/Envs&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After running the commands above, open the &lt;strong&gt;.bashrc&lt;/strong&gt; file via gedit or any other tool you prefer.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ gedit ~/.bashrc&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And add below lines at the end of &lt;strong&gt;.bashrc&lt;/strong&gt; file.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;WORKON_HOME=~/Envs&lt;/code&gt;&lt;br&gt;
&lt;code&gt;VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3&lt;/code&gt;&lt;br&gt;
&lt;code&gt;. /usr/local/bin/virtualenvwrapper.sh&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NXsrGnGe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i05g440tneicu1myblol.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NXsrGnGe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i05g440tneicu1myblol.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can now use &lt;code&gt;mkvirtualenv&lt;/code&gt;, &lt;code&gt;rmvirtualenv&lt;/code&gt; and &lt;code&gt;workon&lt;/code&gt; commands to create, remove and list virtual environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create a new virtualenv&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;$ mkvirtualenv myproject&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jsguru@ubuntu:~$ mkvirtualenv myproject
Using base prefix '/usr'
New python executable in /home/jsguru/Envs/myproject/bin/python3
Also creating executable in /home/jsguru/Envs/myproject/bin/python
Installing setuptools, pip, wheel...
done.
virtualenvwrapper.user_scripts creating /home/jsguru/Envs/myproject/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/jsguru/Envs/myproject/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/jsguru/Envs/myproject/bin/preactivate
virtualenvwrapper.user_scripts creating /home/jsguru/Envs/myproject/bin/postactivate
virtualenvwrapper.user_scripts creating /home/jsguru/Envs/myproject/bin/get_env_details
(myproject) jsguru@ubuntu:~$ 

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Load or switch between virtualenvs&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;$ workon myanotherproject&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(myproject) jsguru@ubuntu:~$ workon
myanotherproject
myproject
(myproject) jsguru@ubuntu:~$ workon myanotherproject
(myanotherproject) jsguru@ubuntu:~$ 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Deactivate a virtualenv&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;$ deactivate&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(myanotherproject) jsguru@ubuntu:~$ deactivate
jsguru@ubuntu:~$ 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Remove a virtualenv&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;$ rmvirtualenv myanotherproject&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;jsguru@ubuntu:~$ workon
myanotherproject
myproject
jsguru@ubuntu:~$ rmvirtualenv myanotherproject
Removing myanotherproject...
jsguru@ubuntu:~$ workon
myproject
jsguru@ubuntu:~$ 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>python</category>
      <category>ubuntu</category>
    </item>
    <item>
      <title>Programmatically determine OS is up to date or outdated on windows or mac osx .</title>
      <dc:creator>jsguru</dc:creator>
      <pubDate>Fri, 31 Jan 2020 10:38:19 +0000</pubDate>
      <link>https://dev.to/jsgurugit/how-to-check-if-os-is-up-to-date-or-outdated-on-windows-or-mac-osx-programmatically-4g08</link>
      <guid>https://dev.to/jsgurugit/how-to-check-if-os-is-up-to-date-or-outdated-on-windows-or-mac-osx-programmatically-4g08</guid>
      <description>&lt;p&gt;Recently I have developed Software for Windows and Mac osx.&lt;br&gt;
Here I needed to determine my os is up to date or outdated programmatically.&lt;/p&gt;

&lt;p&gt;For windows version, programming language is C# and for mac osx version, swift is used.&lt;/p&gt;

&lt;p&gt;I could implement the function in C# because there are C# code snippet related my purpose over internet.&lt;/p&gt;

&lt;p&gt;But unfortunately, no luck for Mac osx and swift.&lt;br&gt;
There are too much articles to get Mac osx or iOS version.&lt;br&gt;
They was not my concerns.&lt;/p&gt;

&lt;p&gt;Below is C# implementation for windows version.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="nf"&gt;CheckIsOSUpdated&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;IUpdateSession&lt;/span&gt; &lt;span class="n"&gt;updateSession&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;UpdateSession&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;IUpdateSearcher&lt;/span&gt; &lt;span class="n"&gt;searcher&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="n"&gt;searcher&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;updateSession&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;CreateUpdateSearcher&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;ISearchResult&lt;/span&gt; &lt;span class="n"&gt;updates&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;searcher&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IsInstalled=0 and Type='Software' and IsHidden=0"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;//ISearchResult updates = searcher.Search("IsInstalled=0");&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;updates&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Updates&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Count&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Then the implementation in swift for Mac osx version is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight swift"&gt;&lt;code&gt;&lt;span class="kd"&gt;import&lt;/span&gt; &lt;span class="kt"&gt;SwiftShell&lt;/span&gt;

&lt;span class="kd"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;getIsOSXUpdate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;Bool&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// softwareupdate --list|tee&lt;/span&gt;
    &lt;span class="c1"&gt;// let command = runAsync("softwareupdate", "--list").stdout.runAsync("tee")&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;command&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;runAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"softwareupdate"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"--list"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="n"&gt;command&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;finish&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;NSLog&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"could not collect available updates."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;command&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="nv"&gt;error&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;command&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stderror&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"No new software available"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You may wonder why stderror is used rather than stdout.&lt;br&gt;
When you run softwareupdate --list on terminal, you will see the result like below if your Mac os is up to date.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JSGURUs-Mac:~ jsguru$ softwareupdate --list
Software Update Tool

Finding available software
No new software available.
JSGURUs-Mac:~ jsguru$ 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Strangely, &lt;strong&gt;stdout&lt;/strong&gt; returns &lt;code&gt;"Software Update Tool\n\nFinding available software\n"&lt;/code&gt; and &lt;strong&gt;stderror&lt;/strong&gt; returns &lt;code&gt;"No new software available.\n"&lt;/code&gt;.&lt;br&gt;
That's why &lt;strong&gt;stderror&lt;/strong&gt; is used.&lt;/p&gt;

&lt;p&gt;I hope these code snippets help you.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>swift</category>
    </item>
  </channel>
</rss>
