<?xml version="1.0"?>
<rss version="2.0"><channel><title>Bash Latest Topics</title><link>https://forum.pulseway.com/forum/78-bash/</link><description>Bash Latest Topics</description><language>en</language><item><title>Write back Date from Batchscript into output variable</title><link>https://forum.pulseway.com/topic/4837-write-back-date-from-batchscript-into-output-variable/</link><description><![CDATA[<p>
	Hi!
</p>

<p>
	 
</p>

<p>
	I want to write back the result of the following short script into a custom field to put this at the corresponding machine. How I have to do this?
</p>

<pre class="ipsCode">wmic diskdrive get model</pre>

<p>
	Result is for example:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">Model
Generic MassStorageClass USB Device
Samsung SSD 980 PRO 500GB
Generic MassStorageClass USB Device
WDC WD10EZEX-75M2NA0</span></pre>

<p>
	The result should stored into a custom field for the machine.
</p>

<p>
	 
</p>

<p>
	Thank you for helping!
</p>
]]></description><guid isPermaLink="false">4837</guid><pubDate>Fri, 06 Jan 2023 17:56:45 +0000</pubDate></item><item><title>Could not execute automation ad-hoc script shell</title><link>https://forum.pulseway.com/topic/4920-could-not-execute-automation-ad-hoc-script-shell/</link><description><![CDATA[<p>
	I have a few bash scripts that I want to exit with an error code under certain circumstances, as I want the script to show as failed.
</p>

<p>
	The issue is that the output for the script is empty, except for the line "<span style="color:#000000;font-size:12px;" title="">Could not execute automation ad-hoc script shell"</span>
</p>

<p>
	<span style="color:#000000;font-size:12px;" title="">This only occurs when the exit code is greater than 0.</span>
</p>

<p>
	<span style="color:#000000;font-size:12px;" title="">Example below:</span>
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<p>
			#!/bin/bash<br />
			echo "exiting with exit 2"<br />
			exit 2
		</p>
	</div>
</blockquote>

<p>
	I'd expect the output of the script to be:
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<div style="background-color:#ffffff;color:#000000;font-size:1.15em;padding:5px;">
			<div title="Output">
				<div style="font-size:13px;">
					<span style="color:#000000;">Output</span>
				</div>
			</div>
		</div>

		<div style="background-color:#ffffff;color:rgba(0,0,0,0.87);font-size:13px;">
			<div>
				<div style="border-bottom:1px solid #eeeeee;color:#000000;padding:6px 10px;">
					<div>
						<div>
							<div>
								<span style="color:#000000;font-size:12px;" title="">exiting with exit 2</span>
							</div>
						</div>
					</div>
				</div>
			</div>

			<div>
				<div style="border-bottom:0px;color:#000000;padding:6px 10px;">
					<div>
						<div>
							<div title="">
								<strong style="font-size:12px;">-2</strong>
							</div>

							<div>
								<span style="color:#000000;font-size:12px;" title="">Exit Code</span>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</blockquote>

<p>
	but it looks like this:
</p>

<blockquote class="ipsQuote" data-ipsquote="">
	<div class="ipsQuote_citation">
		Quote
	</div>

	<div class="ipsQuote_contents">
		<div style="background-color:#ffffff;color:#000000;font-size:1.15em;padding:5px;">
			<div title="Output">
				<div style="font-size:13px;">
					<span style="color:#000000;">Output</span>
				</div>
			</div>
		</div>

		<div style="background-color:#ffffff;color:rgba(0,0,0,0.87);font-size:13px;">
			<div>
				<div style="border-bottom:1px solid #eeeeee;color:#000000;padding:6px 10px;">
					<div>
						<div>
							<div>
								<span style="color:#000000;font-size:12px;" title="">Could not execute automation ad-hoc script shell</span>
							</div>
						</div>
					</div>
				</div>
			</div>

			<div>
				<div style="border-bottom:0px;color:#000000;padding:6px 10px;">
					<div>
						<div>
							<div title="">
								<strong style="font-size:12px;">-1</strong>
							</div>

							<div>
								<span style="color:#000000;font-size:12px;" title="">Exit Code</span>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</blockquote>

<p>
	What am I doing wrong?
</p>

<p>
	Linux agent 9.2, running on Ubuntu 22.04
</p>
]]></description><guid isPermaLink="false">4920</guid><pubDate>Wed, 19 Jul 2023 05:46:22 +0000</pubDate></item><item><title>Newbee: Trouble with this "easy" script</title><link>https://forum.pulseway.com/topic/4759-newbee-trouble-with-this-easy-script/</link><description><![CDATA[<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">test_address="8.8.8.8"                                          
tunnel_interfaceWAN="eth0"                                      
tunnel_interfaceVPN="tun1"                                      
init_ping_tries=2    

ping_tries=init_ping_tries
WANup=0

while  [[ $ping_tries -lt 5] &amp;&amp; [ $WANup -eq 0 ]]
do
        if ping -c 1 -W 1 $test_address -I $tunnel_interfaceWAN &gt;/dev/null
  then
                WANup=1
        fi
        ping_tries=$((ping_tries+1))
done

if $WANup -eq 0
  then
        echo "VPN is down because Internet is down [exit 0]"
        exit 0
fi</span></pre>

<p>
	Im pretty new to bash programming, this script should be simple, but I cant seem to figure out why it is not working correctly.
</p>

<p>
	Is there something wrong with the syntax of my while loop or last if statement?
</p>

<p>
	 
</p>
]]></description><guid isPermaLink="false">4759</guid><pubDate>Mon, 27 Jun 2022 22:25:58 +0000</pubDate></item><item><title>Headless unix VBox snapshot creation.</title><link>https://forum.pulseway.com/topic/2129-headless-unix-vbox-snapshot-creation/</link><description><![CDATA[<p>
	Just in case if anyone interested, I'm sharing my script that support Unix headless Virtual Box snapshot creation.
</p>

<p>
	 
</p>

<p>
	I have two VirtualBox machine (Linux, Win10) and both are running under different username.
</p>

<p>
	Since, pulseway is running under root privilege, I should use su to virtualbox user and pass the specific command to shell.
</p>

<p>
	Please update as needed.
</p>

<p>
	Thanks
</p>

<p>
	---------------------------------------------
</p>

<p>
	#!/bin/bash<br>
	NOW=`date +"%m-%d-%Y-%T"`<br>
	SNAPSHOT_NAME_Linux="Linux_$NOW"<br>
	SNAPSHOT_NAME_Win10="Win10_$NOW"<br>
	SNAPSHOT_DESCRIPTION="Snapshot taken on $NOW"
</p>

<p>
	su -l "vboxusername" -c "/usr/bin/VBoxManage snapshot Linux take "$SNAPSHOT_NAME_Linux" --description "$SNAPSHOT_DESCRIPTION"" &amp;<br>
	su -l "vboxusername" -c "/usr/bin/VBoxManage snapshot Win10 take "$SNAPSHOT_NAME_Win10" --description "$SNAPSHOT_DESCRIPTION"" &amp;
</p>

<p>
	exit 0
</p>
]]></description><guid isPermaLink="false">2129</guid><pubDate>Wed, 11 Oct 2017 13:19:50 +0000</pubDate></item><item><title>Built-in Script Raspberry Pi Rasperrian [ Check and Install Updates ]</title><link>https://forum.pulseway.com/topic/3715-built-in-script-raspberry-pi-rasperrian-check-and-install-updates/</link><description><![CDATA[<p>
	Hey,
</p>

<p>
	 
</p>

<p>
	I noticed by deafult the build-in script don't support update check for Rasperrian I have updated the script simply create new script for linux call it update or how you want it.
</p>

<p>
	 
</p>

<pre class="ipsCode">
#!/bin/bash

detect_os() {
  grep -qis "$*" /etc/issue || grep -qis "$*" /etc/centos-release
}

do_update() {
  echo "Detecting OS ... "

  detect_os "Raspbian GNU/Linux" &amp;&amp; echo "Found Raspbian" &amp;&amp; dpkg_update &amp;&amp; return
  detect_os "Debian GNU/Linux" &amp;&amp; echo "Found Debian" &amp;&amp; dpkg_update &amp;&amp; return
  detect_os "Ubuntu" &amp;&amp; echo "Found Ubuntu" &amp;&amp; dpkg_update &amp;&amp; return
  detect_os "CentOS" &amp;&amp; echo "Found CenOS" &amp;&amp; yum_update &amp;&amp; return
  detect_os "Red Hat" &amp;&amp; echo "Found RedHat" &amp;&amp; yum_update &amp;&amp; return
  detect_os "Fedora" &amp;&amp; echo "Found Fedora" &amp;&amp; yum_update &amp;&amp; return
  detect_os "SUSE" &amp;&amp; echo "Found SuSE" &amp;&amp; zypper_update &amp;&amp; return
}

dpkg_update() {
 if [ -x "/usr/bin/apt-get" ];
 then
   echo "Starting update ..."
   apt-get clean &amp;&amp; apt-get update &amp;&amp; apt-get upgrade -y &amp;&amp; apt-get dist-upgrade -y
 else
   echo "'apt-get' package manager not found"
 fi
}

yum_update() {
 if [ -x "/usr/bin/yum" ];
 then
   echo "Starting update ..."
   yum update -y &amp;&amp; yum upgrade -y
 else
   echo "'yum' package manager not found"
 fi
}

zypper_update() {
 if [ -x "/usr/bin/zypper" ];
 then
   echo "Starting update ..."
   zypper --non-interactive update
 else
   echo "'zypper' package manager not found"
 fi
}

do_update</pre>

<p>
	 
</p>
]]></description><guid isPermaLink="false">3715</guid><pubDate>Tue, 27 Oct 2020 15:43:09 +0000</pubDate></item><item><title>Ping and if below x milliseconds then create error sending notification?</title><link>https://forum.pulseway.com/topic/3510-ping-and-if-below-x-milliseconds-then-create-error-sending-notification/</link><description><![CDATA[<p>
	Is there a way I could Ping google.com for example and if below x milliseconds then create error sending notification to my Pulseway devices?
</p>
]]></description><guid isPermaLink="false">3510</guid><pubDate>Sat, 11 Jul 2020 15:11:54 +0000</pubDate></item><item><title>Change System Group Script</title><link>https://forum.pulseway.com/topic/2396-change-system-group-script/</link><description><![CDATA[<p>
	Hi,
</p>

<p>
	So as I start to get used to Pulseway, here's quick script I've made up to change the *Nix/Win computer group on the fly. I haven't yet found an easier way to do it yet.  This seems to work for me so hopefully it helps someone else.<br><br>
	I've just created a Script Category and added a version of this script per customer/group in this folder.  So create your script edit the Group below to suite your requirements.
</p>

<p>
	Linux/Bash Tab
</p>

<pre class="ipsCode">
#!/bin/bash
if [ -f /bin/sed ] 
then
cp /etc/pulseway/config.xml /etc/pulseway/config.xml.backup
/bin/sed -i '/&lt;ComputerInformation Name="" Group="/c\&lt;ComputerInformation Name="" Group="My Company - Linux Servers"/&gt;' /etc/pulseway/config.xml
else
echo "Sed not found!"
fi</pre>

<p>
	Windows/Powershell Tab
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted">
<span class="pln">Set-ItemProperty -Path "HKLM:\Software\MMSOFT Design\PC Monitor\" -Name GroupName -Value "My Company - Windows Servers"</span></pre>

<p>
	 
</p>
]]></description><guid isPermaLink="false">2396</guid><pubDate>Tue, 07 Aug 2018 01:17:01 +0000</pubDate></item><item><title>Ubuntu update</title><link>https://forum.pulseway.com/topic/1828-ubuntu-update/</link><description><![CDATA[<p>
	Hi, maybe this is too simple but I'm using for my Ubuntu machine update. 
</p>

<p>
	Just in case, somebody who also need like me.
</p>

<p>
	 
</p>

<p>
	#!/bin/bash
</p>

<p>
	/usr/bin/apt-get -qy update &gt; /dev/null<br>
	/usr/bin/apt-get -qy dist-upgrade &gt; /dev/null<br>
	exit 0
</p>
]]></description><guid isPermaLink="false">1828</guid><pubDate>Thu, 06 Oct 2016 16:56:44 +0000</pubDate></item></channel></rss>
