You are not logged in.

#1 2016-05-14 10:51:57

sweetthdevil
Member
Registered: 2009-10-20
Posts: 415

YAD Script to control Server - Parsing info to pipe and display

Hello all,

I discovered YAD (Yet Another Display) which allow more than Zenity.
Anyway, I created a script to run regular commands onto a remote archlinux server, the commands output should log into a pipe file and be display within the yad script window.

However no command outputs get into the pipe file, any direction or help would be appreciated.

Many thanks,

#!/bin/bash

TMPDIR="/home/sweetth/yad"

export fpipe=$(mktemp -u --tmpdir="$TMPDIR" yad-pipe.XXXXXXXX)

mkfifo "$fpipe"

fkey=$(($RANDOM * $$))

function run_cmd ()
{
    $1 >> $fpipe
}
export -f run_cmd

trap "rm -f $fpipe" EXIT

yad --plug=$fkey --tabnum=1  \
    --text="<b><u>What's yourCommand</u>:</b>" \
    --form --columns=3 \
    --field "Start Pyload:BTN" 'bash -c "run_cmd /home/sweetth/yad/startpyload.sh"' \
    --field "Stop Pyload:BTN" 'bash -c "run_cmd /home/sweetth/yad/stoppyload.sh"' \
    --field "Upload Pyload:BTN" 'bash -c "run_cmd /home/sweetth/yad/uploadpyload.sh"' \
    --field "Reset Pyload:BTN" 'bash -c "run_cmd /home/sweetth/yad/resetpyload.sh"' \
    --field "Extract Files:BTN" 'bash -c "run_cmd /home/sweetth/yad/extractfiles.sh"' \
    --field "Rename TV Show:BTN" "bash -c '/home/sweetth/Documents/Scripts/Rename_TV-Show.sh'" \
    --field "Delete Rar:BTN" 'bash -c "run_cmd /home/sweetth/yad/deleterar.sh"' \
    --field "Mount GoFlex:BTN" 'bash -c "run_cmd /home/sweetth/yad/mountgoflex.sh"' \
    --field "Umount GoFlex:BTN" 'bash -c "run_cmd /home/sweetth/yad/umountgoflex.sh"' \
    --field "Reboot GoFlex:BTN" 'bash -c "run_cmd /home/sweetth/yad/reboot.sh"' \
    --field "PowerOff GoFlex:BTN" 'bash -c "run_cmd /home/sweetth/yad/poweroff.sh"' &

tail -f --pid=$$ $fpipe | yad --plug=$fkey --tabnum=2 --text-info &

yad --title "Server Commander" --center --paned --key="$fkey" --button="gtk-close:1" \
    --width=600 --height=300

Last edited by sweetthdevil (2016-05-15 11:51:22)

Offline

#2 2016-05-19 10:31:02

sweetthdevil
Member
Registered: 2009-10-20
Posts: 415

Re: YAD Script to control Server - Parsing info to pipe and display

Right,

Done some investigation and test. Most of the script it run are to be run on a server as mention. I.E. /deleterar.sh run "ssh 192.168.0.4 rm /mnt/hd/Download/*.rar" 

So to resolve the issue I amended those script to log the commands output to the pipe file:

#! /bin/bash
#Logging setup
pipe=$(find /home/sweetth/yad/yad*.pipe) 

command &> $pipe

This then work when the command is local i.e. mount /mnt/share (so run on the computer) as soon as the command is run on the server "ssh ... " then no output are logged. Is it possible to log the output of the ssh to the local file?

I hope that clear enough?

Offline

Board footer

Powered by FluxBB