Jump to content
FijiDave

Parse Terminal Text

Recommended Posts

I want to be able to get information from my servers.  I have a workflow setup that already runs ssh, runs a command and exits.


How do i capture the data to use it in a notification or such?  I have tried reading the help and looked at others scripts but dont see anything related to the terminal. 


Can anyone point me in the right direction?  The text will always have the same text at the beginning but different answer like diskspace or random url 

Share this post


Link to post

Hi @FijiDave,  welcome to the forum.

 

2 hours ago, FijiDave said:

I have tried reading the help and looked at others scripts but dont see anything related to the terminal.

 

To be clear, what you're asking is not about the terminal, which is a GUI program in which users can run a shell (like Terminal.app or iTerm2.app). Alfred does have a Terminal Command action, but that's definitely not what you want if you're trying to capture the output.

 

This is actually very simple to do. Add a Run Script action to your workflow with Language = /bin/bash (or /bin/zsh), and then enter your ssh command in the Script box. That's it. The output of the command will be passed as input to the next workflow element (a Post Notification output or whatever).

 

So if you want to see the space remaining on /dev/sda of server.example.com, you would put the following in the Script box, just like you would type in your shell:

ssh server.example.com df -h | grep /dev/sda | awk '{print $4}'

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...