Navigation

    ML
    • Register
    • Login
    • Search
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    1. Home
    2. Tags
    3. bash
    Log in to post

    • UNSOLVED Redirecting feedback from Linux command
      IT Discussion • linux scripting bash redirect • • JaredBusch  

      7
      0
      Votes
      7
      Posts
      107
      Views

      P

      @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.
    • Script for Creating VMs from Template VM in KVM
      IT Discussion • linux kvm bash automation • • EddieJennings  

      9
      0
      Votes
      9
      Posts
      128
      Views

      P

      @EddieJennings said in Script for Creating VMs from Template VM in KVM: @travisdh1 said in Script for Creating VMs from Template VM in KVM: @EddieJennings said in Script for Creating VMs from Template VM in KVM: @Pete-S said in Script for Creating VMs from Template VM in KVM: Not the exactly the same thing but you might want to look into how to create a VM from scratch. Meaning a script that will set up a VM with vCPU, memory, storage, network etc and then boot it from iso and have it do an unattended install, create what users you want and install the packages you need. That's one of the next things I'm looking into. @EddieJennings Also remember about things like kickstart in RedHat based operating systems. In Fedora/CentOS/RHOS you can use a kickstart file to automatically select all the install time options for the OS. A short time later you've got a fresh server and all the time it took you to setup was running the creation script on your hypervisor. One of the things I'll need to figure out going the Kickstart route is setting the hostname what I want it to be at the time of installation. Likely not difficult to do, I just have to figure it out. Or perhaps, I can just truly take the approach of just making a clean minimal install, and then later configure to whatever specific thing I'm wanting the VM to do for my lab / testing. Inside the kickstart file you'll find something like this: network --hostname=centos8-4.example.com We use debian as our goto and then it's called a preseed file. The only real thing that can be tricky is to tell the installation what kickstart/preseed file you want to use. You can do it in different ways. If you don't want to rely on dhcp/tftp/pxe etc you can roll your own iso file. I think the kickstart file can also be mounted as a drive that the installation will detect when it starts. I think the best approach is to make an automated installation with same basic settings and some of those will get changed later in the installation. For example you can use a fixed hostname that is later changed from ansible.
    • SOLVED VitalPBX setup script on Vultr
      IT Discussion • linux vultr scripting bash shell vitalpbx • • JaredBusch  

      5
      0
      Votes
      5
      Posts
      74
      Views

    • P

      SOLVED Searching for text in file
      IT Discussion • linux bash grep • • Pete.S  

      7
      0
      Votes
      7
      Posts
      110
      Views

      @Obsolesce said in Searching for text in file: @dafyre said in Searching for text in file: @Pete-S said in Searching for text in file: If you have a text file that looks like this: start_folder='/folder1/abc.txt' iterations='123' passphrase='xyz' last_command='invoke' return_value='0' How can you pick out just xyz when looking for "passphrase"? I know grep will get me the line but what should I use if I want just a part of the line? Can it be done in one command or do I have to pipe several together? If you the text has a character that would be a good delimiter, you can pipe grep to cut... ie: cat myfile.txt|grep "iterations"|cut -d '=' -f 2 Output: '123' the -f # is which column you want. There may be other ways to do it, but that's the first way I can think of. You can specify a file with grep, no need to pipe in from cat. This is true! I always seem to get it backwards when I do that, so i just cat $thefile | grep | blah ... Cuts down on frustration, ha ha.
    • What is a For Loop
      Developer Discussion • bash loops • • scottalanmiller  

      21
      3
      Votes
      21
      Posts
      162
      Views

      I did some experimenting... but it's not always the case, it depends on what you are doing. But doing this with simple counting results: And for fun lol....
    • Script to Move and Decrypt Files in a Specified Directory
      IT Discussion • bash gpg • • wirestyle22  

      13
      0
      Votes
      13
      Posts
      143
      Views

      This week was a learning experience. #!/usr/bin/env bash source "/home/datatransfer/company/master.sh" encryptedFolderPath="/home/datatransfer/company/in /" decryptedFolderPath="/home/datatransfer/company/out" archiveFolderPath="/home/datatransfer/company/archive" for i in $(ls $encryptedFolderPath.pgp) do gpg --batch --passphrase $PASS --list-only --list-packets --yes $i | grep -q "encrypted" if [ $? != 0 ]; then echo "$i is not a pgp file" continue fi v=${i%.} encryptedFile="$v" fileName=${encryptedFile##/} timeNow=$(date +%Y%m%d%H%M) extension=${fileName##.} newFileName=${fileName%.*} fileWithTimestamp="$newFileName""_""$timeNow.$extension" gpg --batch –passphrase $PASS --yes --decrypt $i > $decryptedFolderPath/$fileWithTimestamp ls -lr $decryptedFolderPath/$fileWithTimestamp if [ $? != 0 ]; then echo "$fileWithTimestamp is not a readable file" continue fi mv $i $archiveFolderPath done Thanks to @scottalanmiller @stacksofplates and my friend Erik
    • UNSOLVED bash script help splitting string
      IT Discussion • scripting bash arrays • • JaredBusch  

      3
      0
      Votes
      3
      Posts
      92
      Views

      @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
    • SOLVED pull substring from string in bash
      IT Discussion • asterisk scripting bash • • JaredBusch  

      4
      0
      Votes
      4
      Posts
      68
      Views

      said script [[email protected] ~]$ 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
    • nohup
      IT Discussion • linux bash shell nohup • • Emad R  

      6
      2
      Votes
      6
      Posts
      165
      Views

      This is what I do when I use nohup. I usually create a file with the current pid just in case I need to stop it. nohup wget 'https://example.com/fedora.iso' > wget_fedora.log 2>&1 & echo $! > wget_fedora_pid.txt kill -9 `cat wget_fedora_pid.txt` rm wget_fedora_pid.txt
    • Locating a script that you don't know the name of in Linux
      IT Discussion • linux bash • • wirestyle22  

      59
      2
      Votes
      59
      Posts
      474
      Views

      @wirestyle22 usually they are stored in /usr/local/bin that is why you can run them anywhere
    • Tracking Down Ubuntu BASH Session Closing
      IT Discussion • linux ubuntu ssh bash shell ubuntu 16.04 ubuntu 18.04 openssh zsh • • scottalanmiller  

      45
      1
      Votes
      45
      Posts
      410
      Views

      @scottalanmiller said in Tracking Down Ubuntu BASH Session Closing: @matteo-nunziati said in Tracking Down Ubuntu BASH Session Closing: @scottalanmiller said in Tracking Down Ubuntu BASH Session Closing: If I use zsh, I'm good. If I enter BASH from zsh, I get kicked out after several seconds. Definitely is something to do with BASH. Stupid tryout: use bash and then enter zsh before being kicked out. Still out? To understand if it is the firing of bash itself or the stay in bash... No, the underlying bash remains until the ZSH closes. Same as if you were running top from it, for example. So basically bash is able to run long running jobs with your user... It's the interactivity with the shell to be broken... Meh. Sorry the thread is long, did you mention any test from zsh with: Bash <-- ok this kills the session Bash -i any difference??? Bash -l ??? bash --norc bash --noprofile From bashman page
    • Shell Speeds, Bash and PowerShell
      IT Discussion • powershell bash shell • • scottalanmiller  

      91
      0
      Votes
      91
      Posts
      1292
      Views

      ^^^ It's always hilarious when a scumbag scammer thinks their input is valuable.
    • Make this command better
      IT Discussion • scripting bash rsync sed directory comparison • • JaredBusch  

      5
      1
      Votes
      5
      Posts
      179
      Views

      M

      @JaredBusch : I'm not certain if this fits the bill, but what about the "diff" command? Of course, this does nothing to sync the files but does offer a way to simply compare the directories. diff -rs manxam jaredbusch This will get you : Files /home/manxam/TEST and /home/jaredbusch/TEST are identical Only in /home/manxam: i_am_manxam Only in /home/jaredbusch: you_are_jared
    • OSX Shell Error Operation Not Permitted
      IT Discussion • security apple scripting bash osx shell troubleshooting brew quarantine • • DustinB3403  

      2
      2
      Votes
      2
      Posts
      200
      Views

      Just used this again today, as another script I have had this attribute. Not sure when the attribute was written to the script though. But it's working now. This is the full error. /bin/sh: bad interpreter: Operation not permitted
    • Text file manipulation into CSV
      IT Discussion • powershell bash • • PenguinWrangler  

      21
      0
      Votes
      21
      Posts
      727
      Views

      P

      @penguinwrangler Good work! I admit I would have been to lazy to go through all that. I would just have written a program to deal with it straight up instead instead of trying to use nix commands and scripting. Anything to avoid "escape hell" as I like to call it.
    • NextCloud Automated Installation
      IT Discussion • linux storage fedora nextcloud bash cloud storage script selinux installer • • scottalanmiller  

      76
      6
      Votes
      76
      Posts
      5895
      Views

      W

      Is there anything new with updating the script?
    • Get Started with Powerline on Ubuntu
      IT Discussion • linux ubuntu linux desktop bash ubuntu 17.04 powerline • • scottalanmiller  

      7
      3
      Votes
      7
      Posts
      4925
      Views

      @stacksofplates That's what i loked about it while reading on it.
    • A script to pull updates from GH or use History
      IT Discussion • xen orchestra bash xo xen orchestra community xen orchestra updater • • DustinB3403  

      18
      0
      Votes
      18
      Posts
      1791
      Views

      @stacksofplates said in A script to pull updates from GH or use History: @DustinB3403 said in A script to pull updates from GH or use History: So to clarify here, the goal is to allow admins an easy way to pull the most current update script. Not to run it for them on a set schedule. (reason being is if we auto-force an update, and that update breaks their system, I don't want to have that on my mind) I don't understand the hangup here. The cron job I pasted above does not update anything. It doesn't run any scripts. It doesn't force anything. Where this is coming from I have no idea. This is from sidebar conversations regarding the topic. It has nothing to do with the cron job you posted.
    • Script to kill multiple app spawns
      IT Discussion • linux bash script • • stacksofplates  

      4
      1
      Votes
      4
      Posts
      722
      Views

      I guess I could do a wildcard at the beginning and end of whatever I'm searching for with killall but that freaks me out a little. I could accidentally do a lot of damage with that.
    • QEMU Convert Script
      IT Discussion • linux kvm bash script qemu qcow2 preallocation • • stacksofplates  

      1
      4
      Votes
      1
      Posts
      1147
      Views

      No one has replied

    • Linux FAQ: Why Do We Need a Dot Slash Before a Local Command
      IT Discussion • linux security unix sam linux administration bash shell linux system administration zsh ksh tcsh csh • • scottalanmiller  

      1
      0
      Votes
      1
      Posts
      1139
      Views

      No one has replied

    • Cleaner BASH Scripting with a Main Function
      IT Discussion • linux unix scripting bash shell scripting • • scottalanmiller  

      1
      4
      Votes
      1
      Posts
      527
      Views

      No one has replied

    • Scripting FDisk on Linux
      IT Discussion • linux scripting bash fdisk • • scottalanmiller  

      1
      2
      Votes
      1
      Posts
      931
      Views

      No one has replied

    • Working with Linux Shell Limits
      IT Discussion • linux bash shell limits ulimit bash shell limits • • scottalanmiller  

      1
      1
      Votes
      1
      Posts
      721
      Views

      No one has replied

    • What Can BASH on Windows Do?
      IT Discussion • windows bash wls • • scottalanmiller  

      53
      2
      Votes
      53
      Posts
      10733
      Views

      @mlnews said: And this is the current site for the project... https://github.com/Pash-Project/Pash I love it when people port garbage to other platforms
    • Windows Insider Build Has BASH Now
      News • windows bash • • mlnews  

      4
      3
      Votes
      4
      Posts
      838
      Views

      I'm downloading as well. https://blogs.windows.com/windowsexperience/2016/04/06/announcing-windows-10-insider-preview-build-14316/
    • Microsoft is adding the Linux command line to Windows 10
      News • linux windows 10 bash • • Ambarishrh  

      3
      0
      Votes
      3
      Posts
      735
      Views

      Double post: http://mangolassi.it/topic/8668/the-bash-shell-is-coming-to-windows
    • Using CURL and Screen Scraping To Track Topic Performance in NodeBB
      IT Discussion • nodebb mangolassi bash curl • • scottalanmiller  

      1
      2
      Votes
      1
      Posts
      668
      Views

      No one has replied

    • Using Curl to Access Spiceworks
      IT Discussion • bash spiceworks scottalanmiller curl • • scottalanmiller  

      1
      1
      Votes
      1
      Posts
      745
      Views

      No one has replied

    • Basic Web Automation for Collecting Activity
      IT Discussion • bash spiceworks screen scraping web automation • • scottalanmiller  

      2
      0
      Votes
      2
      Posts
      843
      Views

      Before this script will run properly, you have to use curl and a valid account to acquire a cookie to pass with the script, as well.