ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login
    1. Topics
    2. Tags
    3. scripting
    Log in to post
    • All categories
    • gjacobseG

      winget vs choco

      Watching Ignoring Scheduled Pinned Locked Moved IT Discussion choco chocolatey winget package manager package management windows10 window 11 command line scripting scripts script
      4
      0 Votes
      4 Posts
      734 Views
      DanpD

      Check out WingetUI, which can manage packages for choco, scoop, and winget.

    • JaredBuschJ

      beyond bash shell scripting, what language should I use

      Watching Ignoring Scheduled Pinned Locked Moved Unsolved IT Discussion bash scripting linux fedora debian python go
      20
      1 Votes
      20 Posts
      3k Views
      scottalanmillerS

      @jaredbusch said in beyond bash shell scripting, what language should I use:

      @scottalanmiller said in beyond bash shell scripting, what language should I use:

      @jaredbusch said in beyond bash shell scripting, what language should I use:

      @stacksofplates said in beyond bash shell scripting, what language should I use:

      @jaredbusch said in beyond bash shell scripting, what language should I use:

      @scottalanmiller said in beyond bash shell scripting, what language should I use:

      Go is great as a language. But like Ruby, not installed generally. And fewer resources. If it was a greenfield new OS, yeah, Go for sure. But for practical reasons, Python I think.

      As these are systems that I control, there is no reason Go cannot be installed.

      Between your comments and prior ones from @stacksofplates I think I might try Go in order to learn it.

      You normally wouldn't install it anyway as it's not a scripting language. You'd just compile your binary and ship that to your systems.

      I completely misunderstood that about Go. Okay, I will do a bit of checking and decide what I want to do.

      oh sorry, I figured you knew. That's why I never look at it, I don't want to deal with binaries in that way. But nothing wrong with that. Write it on your machine at home, compile, ship binary. Works just fine.

      As fixed tasks, this is not a bad solution. So I will keep it in mind.

      Right, no big deal in this case.

    • EddieJenningsE

      Unifi Controller Installer Script for Ubuntu 21.04

      Watching Ignoring Scheduled Pinned Locked Moved IT Discussion bash unifi controller ubuntu 21.04 mongodb scripting
      7
      5 Votes
      7 Posts
      3k Views
      stacksofplatesS

      @dbeato said in Unifi Controller Installer Script for Ubuntu 21.04:

      @voip_n00b said in Unifi Controller Installer Script for Ubuntu 21.04:

      @stacksofplates docker is worse than reddit. I can’t believe you would suggest such hot garbage.

      How is it garbage @VoIP_n00b ? It is quite possible if someone wants to run their Controller as a container. I am not sure why you are also comparing Reddit with Docker, what is the comparison?

      I think it's an attempt at trolling.

    • JaredBuschJ

      I need this script to email the log it generates

      Watching Ignoring Scheduled Pinned Locked Moved Unsolved IT Discussion scripting email log freepbx
      24
      0 Votes
      24 Posts
      3k Views
      1

      @stacksofplates said in I need this script to email the log it generates:

      @Pete-S said in I need this script to email the log it generates:

      OK, I understand. Thanks.

      Also, I wasn't trying to be abrasive. I kind of worded that strongly. I just don't like Bash much. I find it annoying, so I'd rather use something else unless it's a really simple thing.

      No problem. Bash is primitive for sure. Pick the right tool for the job I guess.

    • EddieJenningsE

      YouTube Months in Review: September, October, and November 2020

      Watching Ignoring Scheduled Pinned Locked Moved Self Promotion youtube linux powershell career advice interview scripting
      1
      0 Votes
      1 Posts
      428 Views
      No one has replied
    • JaredBuschJ

      Redirecting feedback from Linux command

      Watching Ignoring Scheduled Pinned Locked Moved Unsolved IT Discussion linux bash scripting redirect
      7
      0 Votes
      7 Posts
      924 Views
      1

      @JaredBusch said in Redirecting feedback from Linux command:

      @Pete-S Pretty much what I do not want is the status bar from these two commands.

      fwconsole ma upgradeall

      fwconsole chown

      Well, use grep to match for the progress bar then.

      First output stderr to a file and look in the file.

      I don't know how the progress bar looks when it's output as a stream of characters.
      I'm guessing every update is something like

      3076094/3076094 [===========>-------------] 60%<CR>

      In that case grep for every line that doesn't contain a [ followed by a number of =, > or - and finally a ].

      So something like:

      grep -v '\[[=->]+\\]'

      Or maybe even better:

      grep -v '\[[=->]{28}\\]'

      Above assuming there are always 28 characters inside the brackets in the progress bar.

      PS.
      Funny thing but there seems to be a bug in the forum software.
      I had to use an extra backslash to get the above regex look right \[[=->]+\\\] instead of \[[=->]+\\]
      They look right in the preview though.

    • DustinB3403D

      Powershell variable help

      Watching Ignoring Scheduled Pinned Locked Moved IT Discussion powershell scripting
      23
      0 Votes
      23 Posts
      2k Views
      1

      @DustinB3403 said in Powershell variable help:

      @Pete-S That is going to be complete subjective based on the type of spam that might come in.

      I follow what you're saying but I'm kind of stuck between having something functional or not (due to this).

      Well, you need to decide what you are allowing and not. For instance you have already decided to just use the subject line and not any of the other parts of the email, for instance author.

      You need to run the string through regex or something like that to remove characters you are not allowing. It might take more than one string operation to sanitize. I think you can escape any special character you want to allow with backtick `.

      Another option would be to allow the user to enter the entire KQL query themselves.

      Also if you get an error when trying to apply the search you put out an error "Invalid search input!" and go back to prompt the user for input again. That would be one way so solve problems.

    • JaredBuschJ

      Anyone have a script I can tweak to reencode my h264 media to hevc

      Watching Ignoring Scheduled Pinned Locked Moved Unsolved IT Discussion scripting hevc h265 h264
      17
      1 Votes
      17 Posts
      2k Views
      scottalanmillerS

      @JaredBusch said in Anyone have a script I can tweak to reencode my h264 media to hevc:

      @Pete-S said in Anyone have a script I can tweak to reencode my h264 media to hevc:

      If you have a larger movie collection say 10,000 movies @ 90 minutes runtime, you'll have 30,000 hours of encoding ahead of you before you've finished that job. That will take 3.5 years.

      And who would legally have something like that? Anyone who was in that scenario would just ☠ download as needed.

      I don't, but had I stayed collecting like I used to, I'd be pretty close at this point.

    • JaredBuschJ

      VitalPBX setup script on Vultr

      Watching Ignoring Scheduled Pinned Locked Moved Solved IT Discussion vitalpbx vultr linux shell bash scripting
      5
      0 Votes
      5 Posts
      800 Views
      JaredBuschJ

      e0defcac-7cf0-4601-8e04-178a60ea74ed-image.png

    • JaredBuschJ

      Monitor Trunk Failures in FreePBX

      Watching Ignoring Scheduled Pinned Locked Moved IT Discussion freepbx scripting
      4
      4 Votes
      4 Posts
      2k Views
      NashBrydgesN

      This is going to save me time. Was just starting to look at this.

    • JaredBuschJ

      bash script help splitting string

      Watching Ignoring Scheduled Pinned Locked Moved Unsolved IT Discussion bash scripting arrays
      3
      0 Votes
      3 Posts
      620 Views
      JaredBuschJ

      @matteo-nunziati said in bash script help splitting string:

      try this:

      # initializing agi variables declare -a array while read -e ARG && [ "$ARG" ] ; do array=(` echo "$ARG" | sed -e 's/://'`) export ${array[0]}=${array[@]:1} #next added line for debug only. comment this out in prod. echo "${array[0]}=${array[@]:1}" done

      if you want to "slice" an array use the syntax: ${array[@]:from:to}, not providing the 'to' arg means go up to the end of array.
      source here.

      Almost right. Because of the export command parsing spaces, I needed to stick it in a variable first.

      # Variable to hold the details for the log file DUMPARG=" Begin Argument dump:\n" # Create an Array to hold the results of the loop declare -a array # Loop through the AGI variables while read -e ARG && [ "$ARG" ] ; do # Dump them into an array, after removing the : array=(` echo $ARG | sed -e 's/://'`) # take the array and create a variable from the first element put the rest as the value # value must be put into a holding variable to parse correctly by the export command val=${array[@]:1} export ${array[0]}="$val" # Dump them into a string for the log file DUMPARG="$DUMPARG $ARG\n" done
    • JaredBuschJ

      Use a script and systemd timer to keep the FreePBX tftpboot directory up to date with a git repository

      Watching Ignoring Scheduled Pinned Locked Moved IT Discussion freepbx config file git scripting systemd systemd timers
      1
      3 Votes
      1 Posts
      602 Views
      No one has replied
    • JaredBuschJ

      Starting to work on an initial FreePBX setup script

      Watching Ignoring Scheduled Pinned Locked Moved IT Discussion freepbx scripting setup
      13
      8 Votes
      13 Posts
      1k Views
      JaredBuschJ

      @scottalanmiller said in Starting to work on an initial FreePBX setup script:

      Corrected the title to FreePBX instead of FeePBX, lol. Although that name would be useful somewhere, too.

      go me

    • JaredBuschJ

      pull substring from string in bash

      Watching Ignoring Scheduled Pinned Locked Moved Solved IT Discussion bash scripting asterisk
      4
      0 Votes
      4 Posts
      547 Views
      JaredBuschJ

      said script

      [jbusch@pbx ~]$ cat unpause_all.sh #!/bin/sh set -e rasterisk -x "queue show ${1}" | grep paused | grep -o Local.*/n | while read -r member do rasterisk -x "queue unpause member ${member} queue ${1}" done
    • JaredBuschJ

      Need a Powershell script to move these files

      Watching Ignoring Scheduled Pinned Locked Moved Unsolved IT Discussion powershell scripting
      10
      1 Votes
      10 Posts
      705 Views
      JaredBuschJ

      Going to work on this, finally, after dinner tonight.

      Thanks for those that posted.

    • WrCombsW

      How did you learn?

      Watching Ignoring Scheduled Pinned Locked Moved Water Closet powershell scripting noob
      15
      0 Votes
      15 Posts
      958 Views
      EddieJenningsE

      @WrCombs said in How did you learn?:

      How did you learn Power-shell scripting?
      any books worth looking at? Looking at expanding some more, and I know Automation makes jobs way easier.

      This (https://channel9.msdn.com/Series/GetStartedPowerShell3/01) combined with doing tasks in PowerShell. In my opinion, as others have states, it's easier to learn via doing tasks. Added bonus is you complete a task with PowerShell or script it, then see if / how you can improve your script.

    • JaredBuschJ

      Cleanup script help

      Watching Ignoring Scheduled Pinned Locked Moved Solved IT Discussion scripting backup
      7
      1 Votes
      7 Posts
      446 Views
      JaredBuschJ

      ok this is what I came up with.

      #!/bin/bash # Send everything to logs and screen. exec 1> >(logger -s -t $(basename $0)) 2>&1 # Variables and descriptions of their use. # Array of dates found in the filename of the backup files. arrDates=() # Number of full backup sets to keep. keep=4 # How many full backup sets have been found. found=0 # Bas path to the backup files, minus the last folder. base="/home/jbusch/" # Full path to the backup files, populated by the script. path="" # This script requires that the final folder name be passed as a paramter. # This is because it is designed to be ran independently for each subfolder. # ex: ./file_cleanup.sh Hartford # ex: ./file_cleanup.sh Seymour #check for the path to be passed if [ ! -z "$1" ] then # Create the full path to be checked based on the passed parameter. path=$base$1 else exit 127 fi printf "Executing cleanup of backup files located in $path.\n" # Loop through all of the files in the path and parse out an array of the file dates from the file names. # All backups are named `backup-0000001-YYYYMMDD-XXXX*`. cd $path for f in backup-* do # The date is from character 15 for 8 characters. arrDates=("${arrDates[@]}" "${f:15:8}") done cd ~ # Sort in reverse order and only show unique dates. arrDates=($(printf '%s\n' "${arrDates[@]}" | sort -ru)) # Loop through the array of dates and check for there to be 4 files for each date. for checkdate in "${arrDates[@]}" do count=$(find "$path"/backup-0000001-"$checkdate"-* -type f -printf '.' | wc -c) if [ $count -eq 4 ] && [ $found -lt $keep ] then found=$((found+1)) printf "Checking $checkdate, we found $count files. We are keeping this date, currently we have $found dates saved.\n" elif [ $count -gt 0 ] && [ ! $count -eq 4 ] then printf "Incorrect number of files '('$count')' found, removing invalid backup dated $checkdate.\n" rm $path/backup-*-$checkdate-* elif [ $count -gt 0 ] && [ $found -eq $keep ] then printf "We have already found $keep full sets of backup files. Removing backup files dated $checkdate.\n" rm $path/backup-*-$checkdate-* else printf "The date $checkdate returned $count files. This is an unhandled scenario, doing nothing.\n" fi done

      output look like this

      [jbusch@dt-jared FTPTest]$ ./file_cleanup.sh FTPTest <13>Jan 7 16:51:59 file_cleanup.sh: Checking 20200107, we found 4 files. We are keeping this date, currently we have 1 dates saved. <13>Jan 7 16:51:59 file_cleanup.sh: Checking 20200105, we found 4 files. We are keeping this date, currently we have 2 dates saved. <13>Jan 7 16:51:59 file_cleanup.sh: Checking 20200104, we found 4 files. We are keeping this date, currently we have 3 dates saved. <13>Jan 7 16:51:59 file_cleanup.sh: Checking 20200103, we found 4 files. We are keeping this date, currently we have 4 dates saved. <13>Jan 7 16:51:59 file_cleanup.sh: We have already found 4 full sets of backup files. Removing backup files dated 20200102. <13>Jan 7 16:51:59 file_cleanup.sh: We have already found 4 full sets of backup files. Removing backup files dated 20191230. <13>Jan 7 16:51:59 file_cleanup.sh: We have already found 4 full sets of backup files. Removing backup files dated 20191228.
    • JaredBuschJ

      VPS injected ssh keys

      Watching Ignoring Scheduled Pinned Locked Moved IT Discussion ssh ssh keys vps vps security scripting automation
      6
      1 Votes
      6 Posts
      892 Views
      scottalanmillerS

      @JaredBusch said in VPS injected ssh keys:

      Under no circumstances do I actually want anyone's key tied to the root user. It negates all accountability.

      It's for pre-production setup. Not for deploying straight to production.

    • JaredBuschJ

      Need a good example of getting powershell arguments

      Watching Ignoring Scheduled Pinned Locked Moved Unsolved IT Discussion powershell scripting parameters
      3
      1 Votes
      3 Posts
      691 Views
      ObsolesceO

      @JaredBusch said in Need a good example of getting powershell arguments:

      I'll hit the google later, because I am on other things, but I found that something I touched today could very easily be improved if I can add parameter handling to the powershell script.

      Now, the basics are easy as it is all in the $ARGS variable/object.

      But I want to have some safety checking. because it is easier to do things right the first time.

      Example: I want a parameter to note if I should make the thing being done the default.

      I can pass a 1 like dothing.ps1 1 and I can simply code something to check $ARG[0] eq "1" but that is not very explanatory to the person using the script.

      This is more explanatory dothing.ps1 -default for a command.

      So has anyone seen a good example of parameter handling that I can put into my dothing.ps1 script?

      I'm not sure I understand exactly what you mean.

      Taking a guess here, but how I understand is that you'd want to add this at the top of your script:

      [cmdletbinding()] param ( [Parameter()] [Switch]$Default ) if ($Default) { Write-Host "The -Default parameter was specified." } else { Write-Host "The -Default parameter was NOT specified." }

      Doing that will give you the following output:

      PS > .\JBTest.ps1 -Default The -Default parameter was specified. PS > .\JBTest.ps1 The -Default parameter was NOT specified.

      If you want to accept input from a pipeline to work with, let me know.

    • DustinB3403D

      OSX administrators who use Brew - Xcode Tools no longer included by default

      Watching Ignoring Scheduled Pinned Locked Moved IT Discussion osx administration automation brew shell scripting apple xcode
      1
      1 Votes
      1 Posts
      527 Views
      No one has replied
    • 1
    • 2
    • 3
    • 1 / 3