Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Anchor
1154173
1154173
Syntax









Wiki Markup
*diskspace* _logical-name_\[=_path_\] \[_qty_=_nnn_\{*b*\|*k*\|*m*\|*g*\}\] \[_cond_=\{*GT*\|*LT*\}\]









Anchor
1154175
1154175
Description

...


Anchor
1154215
1154215
The following example displays the amount of space available on the volume or file system that contains the directory c:\somedir.

<pre>
open dst=ipaddr user=uid pwd=password
diskspace dst=c:\somedir
</pre>
Panel
Html bobswift


Anchor
1154219
1154219
The following example verifies that the available space for the volume or file system that contains the current working directory is greater than 10GB.

html-bobswift
Panel
<pre>
open dst=ipaddr user=uid pwd=password
diskspace dst qty=10g
if $(_lastrc.result) EQ 0
   echo "At least 10 GB is available"
else
   echo "Less than 10 GB is available"
end
</pre>


Anchor
1154228
1154228
The statements below repeat the previous example using the $(_diskspace) built-in variable with the .gb attribute.

html-bobswift
Panel
<pre>
open dst=ipaddr user=uid pwd=password
diskspace dst
if $(_diskspace.gb) GE 10
   echo "At least 10 GB is available"
else
   echo "Less than 10 GB is available"
end
</pre>


Anchor
1154240
1154240
The following example uses diskspace in the context of a forfiles statement, using the file's size in the comparison.

html-bobswift
Panel


<pre>
open dst=ipaddr user=uid pwd=password
forfiles local=c:\sourcedir\afile.txt fileattrib=yes
   # Make sure we have enough space available
   diskspace dst=c:\targetdir qty=$(_file.size) cond=GT
   
   # We do, copy the file.
   if $(_lastrc.result) EQ 0 
      copy local=$(_file) dst=c:\targetdir\$(_file)
   end
end
</pre>



Anchor
1154258
1154258
The statements below repeat the previous example using the $(_diskspace) built-in variable. The if statement only allows the file copy if the number of bytes available on c: is greater than the size of the input file.

html-bobswift
Panel


<pre>
open dst=ipaddr user=uid pwd=password
forfiles local=c:\sourcedir\afile.txt fileattrib=yes
   # Make sure we have enough space available
   diskspace dst=c:\targetdir

   # We do, copy the file.
   if $(_diskspace) GT $(_file.size)  
      copy local=$(_file) dst=c:\targetdir\$(_file)
   end
end
</pre>



Anchor
1154258
1154258
The following example uses diskspace in the context of a forfiles loop, using the total size of several files to determine the quantity of space needed.

html-bobswift
Panel


<pre>
set spaceNeeded=0
open dst=ipaddr user=uid pwd=password

forfiles local=/home/datadir/*.txt fileattrib=yes
   set spaceNeeded=<$(spaceNeeded) + $(_file.size)>
end

# Make sure we have enough space available
diskspace dst=c:\targetdir qty=$(spaceNeeded) cond=GT
   
# Only execute the "forfiles" statement if we have enough space
# for all the files.
if <"$(_lastrc.message)" EQ "SUCCESS">
   forfiles local=c:\sourcedir\*.txt
      copy local=$(file) dst=c:\targetdir\$(_file)
   end
end
</pre>



Anchor
1154258
1154258
The statements below repeat the previous example using the $(_diskspace) built-in variable.

html-bobswift
Panel


<pre>
set spaceNeeded=0
open dst=ipaddr user=uid pwd=password

forfiles local=/home/datadir/*.txt fileattrib=yes
   set spaceNeeded=<$(spaceNeeded) + $(_file.size)>
end

# Make sure we have enough space available
diskspace dst=c:\targetdir
   
# Only execute the "forfiles" statement if we have enough space
# for all the files.
if $(_diskspace) GT $(spaceNeeded)
   forfiles local=c:\sourcedir\*.txt
      copy local=$(file) dst=c:\targetdir\$(_file)
   end
end
</pre>



Anchor
1154258
1154258
The following example would prevent a copy if the available space for the volume or file system that contains the specified directory is less than 20MB.

html-bobswift
Panel


<pre>
open dst=ipaddr user=uid pwd=password
diskspace dst=c:\targetdir qty=20m cond=lt
if $(_lastrc.result) EQ 0
   echo "Not enough space. Will not copy."
else
   echo "OK to copy"
   copy local=c:\sourcedir\somefile.txt dst=c:\targetdir\somefile.txt
end

The statements below repeat the previous example using the $(_diskspace) built-in variable with the {{.mb}} attribute.  

open dst=ipaddr user=uid pwd=password
diskspace dst=c:\targetdir
if $(_diskspace.mb) LT 20
   echo "Not enough space. Will not copy."
else
   echo "OK to copy"
   copy local=c:\sourcedir\somefile.txt dst=c:\targetdir\somefile.txt
end
</pre>


Anchor
1124154
1124154