Sponsored Content
Top Forums Shell Programming and Scripting remote/automated OS X folder label indexes triggered from PHP Post 302651509 by bradlecat on Tuesday 5th of June 2012 05:56:47 PM
Old 06-05-2012
remote/automated OS X folder label indexes triggered from PHP

I have a shell script that updates OS X color label indexes of folders/files as specified in an XML file. This works from terminal, but not when I trigger it from Apache/PHP. The server is not public, so not too worried about security. I've tried to allow access in sudoers, but no dice. I could use a cron script to make the update, but was really hoping to not need to do that. Any ideas?

line in sudoers:

Code:
www-data ALL=NOPASSWD: /Library/WebServer/Documents/osx_labels/update_labels.sh

Example XML:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<root>
    <entry>
        <name>/Library/WebServer/Documents/osx_labels/ATT-00242 - 1108_1112 Tutorial Videos</name>
        <color>Green</color>
    </entry>
    <entry>
        <name>/Library/WebServer/Documents/osx_labels/ATT-00259 - Differentiated Pricing Mock-ups</name>
        <color>Blue</color>
    </entry>
</root>

update_labels.sh:

Code:
#!/bin/bash
count=1
input=/Library/WebServer/Documents/osx_labels/folders.xml
#input=http://staging.seven2.net/test/folders.xml

while [ -n "$name" -o $count = 1 ]
do
    #iterate XML with xpath to retrieve values and set folder label indexes
    name=`cat $input | xpath //entry[$count]/name 2>/dev/null | sed s/\<name\>//g| sed s/\<\\\\/name\>//g`
    color=`cat $input | xpath //entry[$count]/color 2>/dev/null | sed s/\<color\>//g| sed s/\<\\\\/color\>//g`
    if [ "$name" -a "$color" ]; then
		#setlabel from osxutils by Sveinbjorn Thordarson
		setlabel "$color" "$name" 
    fi
    count=$((count+1))
done

update_labels.php:

Code:
<?php
	$output = shell_exec("sh update_labels.sh");
	echo $output;
?>

---------- Post updated at 04:56 PM ---------- Previous update was at 03:11 PM ----------

I didn't mention that I'm incredibly new at this stuff. I didn't think there were errors, and now I see:

update_labels.sh: line 14: setlabel: command not found
update_labels.sh: line 14: setlabel: command not found

So looks like osxutils commands are recognized only when run from terminal???
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check Remote Folder Exists

Hi, I want to sftp some files to a remote directory. Before transferring files i want to check whether the required folder exists. If so copy the files to that folder, else create the folder and copy the files. Thanks in adv (1 Reply)
Discussion started by: borncrazy
1 Replies

2. UNIX for Dummies Questions & Answers

using sed with indexes

Hi people, Is this possible and if so any tips are very welcome. Im trying to do the following: this is what I have: 800__1__ this is what I want: 8000010 12345678 Im... (1 Reply)
Discussion started by: seaten
1 Replies

3. UNIX for Dummies Questions & Answers

remote folder

hi i want to create a folder that connects to another server. I am going to be running a program that is cpu intensive on server #1, but that same server, server #1, does not have alot of space and therefore can not store the files even temporarly. I want to create a directory on server #1 that... (1 Reply)
Discussion started by: azezal
1 Replies

4. Shell Programming and Scripting

moving a file to a new folder and automated ftp

how to move a file to a different folder after an automated FTP . (1 Reply)
Discussion started by: dineshr85
1 Replies

5. Shell Programming and Scripting

matrix indexes

I wanted to use matrixs in awk and got some problem, here is some of the script code, from the BEGIN tag: row_char="a";row_char="b";row_char="c";row_char="d";row_char="e"$ row_char="h";row_char="i";row_char="j";row_char="k"; from the proccess passage: sentence,1]=1; diffrence=4; i=7;... (2 Replies)
Discussion started by: tal
2 Replies

6. Shell Programming and Scripting

Unzip folder on remote machine

Hi ! I am trying to automate FTP transfer of some folders from one unix machine (a) to another one (b). I run my shell script on machine a. The problem I face is how to unzip the folder at the machine b with script run in machine a. My first question: Is there any way to do this ? My... (10 Replies)
Discussion started by: siba
10 Replies

7. UNIX for Advanced & Expert Users

How to copy folder from one server to remote one using SSH

ok guys. I have a Centos server running a large website I own. Its is severely struggling under the load and I am having to move to a new load balanced setup. The servers are both remote (to me) and although I can do most things admin wise in nix, I am struggling a bit to come up with a way... (1 Reply)
Discussion started by: anderow
1 Replies

8. OS X (Apple)

Automated command ; extracting files from folders and copying them into a single folder

Hello everyone, I'm running Mac OS X Leopard (10.5.8) and I want to use the Terminal to help automate this tedious and laborious command for me: I need to extract all of the .m4p files in my "iTunes Music" folder which reside in folders of the artist, and then subfolders for the albums and... (2 Replies)
Discussion started by: qcom
2 Replies

9. Shell Programming and Scripting

Check if remote folder exists

Hi, When trying to chk if a folder exists on remote server using the below command (got it from other thread in this forum) "ifvchr@s1.mrix.local '/cygdrive/d/shares/projects\ data\ load/test\ files/$SCPED_FILES$name$code'`]; then echo "Directory exists"; else echo "Directory... (0 Replies)
Discussion started by: funonnet
0 Replies

10. Shell Programming and Scripting

How do you compare two folders and copy the difference to a third folder in a remote server?

How do you compare one local folder and a remote folder and copy the difference to a third folder in a remote folder.e.g. Folder A -- Is in a remote server and it has the following files TEST1.OUT TEST2.OUT TEST3.OUT Folder B --Is in a local server and it has the following files ... (5 Replies)
Discussion started by: cumeh1624
5 Replies
IRSEND(1)								FSF								 IRSEND(1)

NAME
irsend - basic LIRC program to send infra-red commands SYNOPSIS
irsend [options] DIRECTIVE REMOTE CODE [CODE...] DESCRIPTION
Asks the lircd daemon to send one or more CIR (Consumer Infra-Red) commands. This is intended for remote control of electronic devices such as TV boxes, HiFi sets, etc. DIRECTIVE can be: SEND_ONCE - send CODE [CODE ...] once SEND_START - start repeating CODE SEND_STOP - stop repeating CODE LIST - list configured remote items SET_TRANSMITTERS - set transmitters NUM [NUM ...] SIMULATE - simulate IR event REMOTE is the name of a remote, as described in the lircd configuration file. CODE is the name of a remote control key of REMOTE, as it appears in the lircd configuration file. NUM is the transmitter number of the hardware device. For the LIST DIRECTIVE, REMOTE and/or CODE can be empty: LIST "" "" - list all configured remote names LIST REMOTE "" - list all codes of REMOTE LIST REMOTE CODE - list only CODE of REMOTE The SIMULATE command only works if it has been explicitly enabled in lircd. -h --help display usage summary -v --version display version -d --device use given lircd socket [/var/run/lirc/lircd] -a --address=host[:port] connect to lircd at this address -# --count=n send command n times EXAMPLES
irsend LIST DenonTuner "" irsend SEND_ONCE DenonTuner PROG-SCAN irsend SEND_ONCE OnkyoAmpli VOL-UP VOL-UP VOL-UP VOL-UP irsend SEND_START OnkyoAmpli VOL-DOWN ; sleep 3 irsend SEND_STOP OnkyoAmpli VOL-DOWN irsend SET_TRANSMITTERS 1 irsend SET_TRANSMITTERS 1 3 4 irsend SIMULATE "0000000000000476 00 OK TECHNISAT_ST3004S" FILES
/etc/lirc/lircd.conf Default lircd configuration file. It should contain all the remotes, their infra-red codes and the corresponding timing and wave- form details. DIAGNOSTICS
If lircd is not running (or /var/run/lirc/lircd lacks write permissions) irsend aborts with the following diagnostics: "irsend: could not connect to socket" "irsend: Connection refused" (or "Permission denied"). SEE ALSO
The documentation for lirc is maintained as html pages. They are located under html/ in the documentation directory. lircd(8), mode2(1), smode2(1), xmode2(1), irrecord(1), irw(1), http://www.lirc.org. irsend 0.8.7pre1 May 2010 IRSEND(1)
All times are GMT -4. The time now is 09:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy