Is it possible to modify this script to include subfolders?
I have tried to do this with no luck. This script works great, but how to I make it apply to all sub-folders? Thanks for any suggestions.
#target bridge
if( BridgeTalk.appName == "bridge" ) {
descToTitle = MenuElement.create("command", "Keys to Title", "at the end of Tools");
descToTitle.onSelect = function () {
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var thumb = app.document.selections;
for(var s in thumb){
if(thumb[s].hasMetadata){
var selectedFile = thumb[s].spec;
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var myXmp = myXmpFile.getXMP();
var Description = getArrayItems(XMPConst.NS_DC, "keywords");
myXmp.deleteProperty(XMPConst.NS_DC, "title");
myXmp.appendArrayItem(XMPConst.NS_DC, "title", Description, 0, XMPConst.ALIAS_TO_ALT_TEXT);
myXmp.setQualifier(XMPConst.NS_DC, "title[1]", "http://www.w3.org/XML/1998/namespace", "lang", "x-default");
function getArrayItems(ns, prop){
var arrItem=[];
try{
var items = myXmp.countArrayItems(ns, prop);
for(var i = 1;i <= items;i++){
arrItem.push(myXmp.getArrayItem(ns, prop, i));
return arrItem;
}catch(e){alert(e +" Line: "+ e.line);}
if (myXmpFile.canPutXMP(myXmp)) {
myXmpFile.putXMP(myXmp);
myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
} else {
xmpFile.closeFile();
I have done that, but for some reason that feature is not working in my copy of Bridge.
Not to mention, I need to do this on thousands of images. That is why the subfolder feature would be helpful.
However, I also thought about creating a collection with all of the images in it.
Similar Messages
-
How can I modify this script to return only certain rows of my mySQL table?
Hi there,
I have a php script that accesses a mySQL database and it was generated out of the Flex Builder wizard automatically. The script works great and there are no problems with it. It allows me to perform CRUD on a table by calling it from my Flex app. and it retrieves all the data and puts it into a nice MXML format.
My question, currently when I call "findAll" to retrieve all the data in the table, well, it retrieves ALL the rows in the table. That's fine, but my table is starting to grow really large with thousands of rows.
I want to modify this script so that I can pass a variable into it from Flex so that it only retrieves the rows that match the "$subscriber_id" variable that I pass. In this way the results are not the entire table's data, only the rows that match 'subscriber_id'.
I know how to pass a variable from Flex into php and the code on the php side to pick it up would look like this:
$subscriberID = $_POST['subscriberID'];
Can anyone shed light as to the proper code modification in "findAll" which will take my $subscriberID variable and compare it to the 'subscriber_id' field and then only return those rows that match? I think it has something to do with lines 98 to 101.
Any help is appreciated.
<?php
require_once(dirname(__FILE__) . "/2257safeDBconn.php");
require_once(dirname(__FILE__) . "/functions.inc.php");
require_once(dirname(__FILE__) . "/XmlSerializer.class.php");
* This is the main PHP file that process the HTTP parameters,
* performs the basic db operations (FIND, INSERT, UPDATE, DELETE)
* and then serialize the response in an XML format.
* XmlSerializer uses a PEAR xml parser to generate an xml response.
* this takes a php array and generates an xml according to the following rules:
* - the root tag name is called "response"
* - if the current value is a hash, generate a tagname with the key value, recurse inside
* - if the current value is an array, generated tags with the default value "row"
* for example, we have the following array:
* $arr = array(
* "data" => array(
* array("id_pol" => 1, "name_pol" => "name 1"),
* array("id_pol" => 2, "name_pol" => "name 2")
* "metadata" => array(
* "pageNum" => 1,
* "totalRows" => 345
* we will get an xml of the following form
* <?xml version="1.0" encoding="ISO-8859-1"?>
* <response>
* <data>
* <row>
* <id_pol>1</id_pol>
* <name_pol>name 1</name_pol>
* </row>
* <row>
* <id_pol>2</id_pol>
* <name_pol>name 2</name_pol>
* </row>
* </data>
* <metadata>
* <totalRows>345</totalRows>
* <pageNum>1</pageNum>
* </metadata>
* </response>
* Please notice that the generated server side code does not have any
* specific authentication mechanism in place.
* The filter field. This is the only field that we will do filtering after.
$filter_field = "subscriber_id";
* we need to escape the value, so we need to know what it is
* possible values: text, long, int, double, date, defined
$filter_type = "text";
* constructs and executes a sql select query against the selected database
* can take the following parameters:
* $_REQUEST["orderField"] - the field by which we do the ordering. MUST appear inside $fields.
* $_REQUEST["orderValue"] - ASC or DESC. If neither, the default value is ASC
* $_REQUEST["filter"] - the filter value
* $_REQUEST["pageNum"] - the page index
* $_REQUEST["pageSize"] - the page size (number of rows to return)
* if neither pageNum and pageSize appear, we do a full select, no limit
* returns : an array of the form
* array (
* data => array(
* array('field1' => "value1", "field2" => "value2")
* metadata => array(
* "pageNum" => page_index,
* "totalRows" => number_of_rows
function findAll() {
global $conn, $filter_field, $filter_type;
* the list of fields in the table. We need this to check that the sent value for the ordering is indeed correct.
$fields = array('id','subscriber_id','lastName','firstName','birthdate','gender');
$where = "";
if (@$_REQUEST['filter'] != "") {
$where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);
$order = "";
if (@$_REQUEST["orderField"] != "" && in_array(@$_REQUEST["orderField"], $fields)) {
$order = "ORDER BY " . @$_REQUEST["orderField"] . " " . (in_array(@$_REQUEST["orderDirection"], array("ASC", "DESC")) ? @$_REQUEST["orderDirection"] : "ASC");
//calculate the number of rows in this table
$rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
$row_rscount = mysql_fetch_assoc($rscount);
$totalrows = (int) $row_rscount["cnt"];
//get the page number, and the page size
$pageNum = (int)@$_REQUEST["pageNum"];
$pageSize = (int)@$_REQUEST["pageSize"];
//calculate the start row for the limit clause
$start = $pageNum * $pageSize;
//construct the query, using the where and order condition
$query_recordset = "SELECT id,subscriber_id,lastName,firstName,birthdate,gender FROM `modelName` $where $order";
//if we use pagination, add the limit clause
if ($pageNum >= 0 && $pageSize > 0) {
$query_recordset = sprintf("%s LIMIT %d, %d", $query_recordset, $start, $pageSize);
$recordset = mysql_query($query_recordset, $conn);
//if we have rows in the table, loop through them and fill the array
$toret = array();
while ($row_recordset = mysql_fetch_assoc($recordset)) {
array_push($toret, $row_recordset);
//create the standard response structure
$toret = array(
"data" => $toret,
"metadata" => array (
"totalRows" => $totalrows,
"pageNum" => $pageNum
return $toret;
* constructs and executes a sql count query against the selected database
* can take the following parameters:
* $_REQUEST["filter"] - the filter value
* returns : an array of the form
* array (
* data => number_of_rows,
* metadata => array()
function rowCount() {
global $conn, $filter_field, $filter_type;
$where = "";
if (@$_REQUEST['filter'] != "") {
$where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);
//calculate the number of rows in this table
$rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
$row_rscount = mysql_fetch_assoc($rscount);
$totalrows = (int) $row_rscount["cnt"];
//create the standard response structure
$toret = array(
"data" => $totalrows,
"metadata" => array()
return $toret;Hi there,
I have a php script that accesses a mySQL database and it was generated out of the Flex Builder wizard automatically. The script works great and there are no problems with it. It allows me to perform CRUD on a table by calling it from my Flex app. and it retrieves all the data and puts it into a nice MXML format.
My question, currently when I call "findAll" to retrieve all the data in the table, well, it retrieves ALL the rows in the table. That's fine, but my table is starting to grow really large with thousands of rows.
I want to modify this script so that I can pass a variable into it from Flex so that it only retrieves the rows that match the "$subscriber_id" variable that I pass. In this way the results are not the entire table's data, only the rows that match 'subscriber_id'.
I know how to pass a variable from Flex into php and the code on the php side to pick it up would look like this:
$subscriberID = $_POST['subscriberID'];
Can anyone shed light as to the proper code modification in "findAll" which will take my $subscriberID variable and compare it to the 'subscriber_id' field and then only return those rows that match? I think it has something to do with lines 98 to 101.
Any help is appreciated.
<?php
require_once(dirname(__FILE__) . "/2257safeDBconn.php");
require_once(dirname(__FILE__) . "/functions.inc.php");
require_once(dirname(__FILE__) . "/XmlSerializer.class.php");
* This is the main PHP file that process the HTTP parameters,
* performs the basic db operations (FIND, INSERT, UPDATE, DELETE)
* and then serialize the response in an XML format.
* XmlSerializer uses a PEAR xml parser to generate an xml response.
* this takes a php array and generates an xml according to the following rules:
* - the root tag name is called "response"
* - if the current value is a hash, generate a tagname with the key value, recurse inside
* - if the current value is an array, generated tags with the default value "row"
* for example, we have the following array:
* $arr = array(
* "data" => array(
* array("id_pol" => 1, "name_pol" => "name 1"),
* array("id_pol" => 2, "name_pol" => "name 2")
* "metadata" => array(
* "pageNum" => 1,
* "totalRows" => 345
* we will get an xml of the following form
* <?xml version="1.0" encoding="ISO-8859-1"?>
* <response>
* <data>
* <row>
* <id_pol>1</id_pol>
* <name_pol>name 1</name_pol>
* </row>
* <row>
* <id_pol>2</id_pol>
* <name_pol>name 2</name_pol>
* </row>
* </data>
* <metadata>
* <totalRows>345</totalRows>
* <pageNum>1</pageNum>
* </metadata>
* </response>
* Please notice that the generated server side code does not have any
* specific authentication mechanism in place.
* The filter field. This is the only field that we will do filtering after.
$filter_field = "subscriber_id";
* we need to escape the value, so we need to know what it is
* possible values: text, long, int, double, date, defined
$filter_type = "text";
* constructs and executes a sql select query against the selected database
* can take the following parameters:
* $_REQUEST["orderField"] - the field by which we do the ordering. MUST appear inside $fields.
* $_REQUEST["orderValue"] - ASC or DESC. If neither, the default value is ASC
* $_REQUEST["filter"] - the filter value
* $_REQUEST["pageNum"] - the page index
* $_REQUEST["pageSize"] - the page size (number of rows to return)
* if neither pageNum and pageSize appear, we do a full select, no limit
* returns : an array of the form
* array (
* data => array(
* array('field1' => "value1", "field2" => "value2")
* metadata => array(
* "pageNum" => page_index,
* "totalRows" => number_of_rows
function findAll() {
global $conn, $filter_field, $filter_type;
* the list of fields in the table. We need this to check that the sent value for the ordering is indeed correct.
$fields = array('id','subscriber_id','lastName','firstName','birthdate','gender');
$where = "";
if (@$_REQUEST['filter'] != "") {
$where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);
$order = "";
if (@$_REQUEST["orderField"] != "" && in_array(@$_REQUEST["orderField"], $fields)) {
$order = "ORDER BY " . @$_REQUEST["orderField"] . " " . (in_array(@$_REQUEST["orderDirection"], array("ASC", "DESC")) ? @$_REQUEST["orderDirection"] : "ASC");
//calculate the number of rows in this table
$rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
$row_rscount = mysql_fetch_assoc($rscount);
$totalrows = (int) $row_rscount["cnt"];
//get the page number, and the page size
$pageNum = (int)@$_REQUEST["pageNum"];
$pageSize = (int)@$_REQUEST["pageSize"];
//calculate the start row for the limit clause
$start = $pageNum * $pageSize;
//construct the query, using the where and order condition
$query_recordset = "SELECT id,subscriber_id,lastName,firstName,birthdate,gender FROM `modelName` $where $order";
//if we use pagination, add the limit clause
if ($pageNum >= 0 && $pageSize > 0) {
$query_recordset = sprintf("%s LIMIT %d, %d", $query_recordset, $start, $pageSize);
$recordset = mysql_query($query_recordset, $conn);
//if we have rows in the table, loop through them and fill the array
$toret = array();
while ($row_recordset = mysql_fetch_assoc($recordset)) {
array_push($toret, $row_recordset);
//create the standard response structure
$toret = array(
"data" => $toret,
"metadata" => array (
"totalRows" => $totalrows,
"pageNum" => $pageNum
return $toret;
* constructs and executes a sql count query against the selected database
* can take the following parameters:
* $_REQUEST["filter"] - the filter value
* returns : an array of the form
* array (
* data => number_of_rows,
* metadata => array()
function rowCount() {
global $conn, $filter_field, $filter_type;
$where = "";
if (@$_REQUEST['filter'] != "") {
$where = "WHERE " . $filter_field . " LIKE " . GetSQLValueStringForSelect(@$_REQUEST["filter"], $filter_type);
//calculate the number of rows in this table
$rscount = mysql_query("SELECT count(*) AS cnt FROM `modelName` $where");
$row_rscount = mysql_fetch_assoc($rscount);
$totalrows = (int) $row_rscount["cnt"];
//create the standard response structure
$toret = array(
"data" => $totalrows,
"metadata" => array()
return $toret; -
Please assist with modifying this script to read in a list of servers and output results to excel
Hello,
I have an excellent script written by Brian Wilhite to gather the last logged in user using Powershell.
http://gallery.technet.microsoft.com/scriptcenter/Get-LastLogon-Determining-283f98ae/view/Discussions#content
My Powershell Fu is stumbling to modify this script to the following requirements:
Currently the script must be loaded first into Powershell, then it can be executed. I would rather edit the script in my Powershell ISE, add the .txt file to the script itself that gives a list of the servers I need to scan. Then when I
press Run Script in my ISE it executes.
I would also like to output the results of the file to excel (.xls or .csv will do). Currently the results look as follows:
Computer : SVR01
User : WILHITE\BRIAN
SID : S-1-5-21-012345678-0123456789-012345678-012345
Time : 9/20/2012 1:07:58 PM
CurrentlyLoggedOn : False
I would prefer it shows up like so:
Computer User SID Time Currently LoggedOn
SVR01 WILHITE\BRIAN S-1xxx 9/20/2012 1:07:58 PM FalseSRV02 WILHITE\BRIAN S-2xxx 9/26/2014 10:00:00 AM True
Any help you can provide would be greatly appreciated. I'll add the full script to the end of this post.
Thank you.
Function Get-LastLogon
<#
.SYNOPSIS
This function will list the last user logged on or logged in.
.DESCRIPTION
This function will list the last user logged on or logged in. It will detect if the user is currently logged on
via WMI or the Registry, depending on what version of Windows is running on the target. There is some "guess" work
to determine what Domain the user truly belongs to if run against Vista NON SP1 and below, since the function
is using the profile name initially to detect the user name. It then compares the profile name and the Security
Entries (ACE-SDDL) to see if they are equal to determine Domain and if the profile is loaded via the Registry.
.PARAMETER ComputerName
A single Computer or an array of computer names. The default is localhost ($env:COMPUTERNAME).
.PARAMETER FilterSID
Filters a single SID from the results. For use if there is a service account commonly used.
.PARAMETER WQLFilter
Default WQLFilter defined for the Win32_UserProfile query, it is best to leave this alone, unless you know what
you are doing.
Default Value = "NOT SID = 'S-1-5-18' AND NOT SID = 'S-1-5-19' AND NOT SID = 'S-1-5-20'"
.EXAMPLE
$Servers = Get-Content "C:\ServerList.txt"
Get-LastLogon -ComputerName $Servers
This example will return the last logon information from all the servers in the C:\ServerList.txt file.
Computer : SVR01
User : WILHITE\BRIAN
SID : S-1-5-21-012345678-0123456789-012345678-012345
Time : 9/20/2012 1:07:58 PM
CurrentlyLoggedOn : False
Computer : SVR02
User : WILIHTE\BRIAN
SID : S-1-5-21-012345678-0123456789-012345678-012345
Time : 9/20/2012 12:46:48 PM
CurrentlyLoggedOn : True
.EXAMPLE
Get-LastLogon -ComputerName svr01, svr02 -FilterSID S-1-5-21-012345678-0123456789-012345678-012345
This example will return the last logon information from all the servers in the C:\ServerList.txt file.
Computer : SVR01
User : WILHITE\ADMIN
SID : S-1-5-21-012345678-0123456789-012345678-543210
Time : 9/20/2012 1:07:58 PM
CurrentlyLoggedOn : False
Computer : SVR02
User : WILIHTE\ADMIN
SID : S-1-5-21-012345678-0123456789-012345678-543210
Time : 9/20/2012 12:46:48 PM
CurrentlyLoggedOn : True
.LINK
http://msdn.microsoft.com/en-us/library/windows/desktop/ee886409(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/system.security.principal.securityidentifier.aspx
.NOTES
Author: Brian C. Wilhite
Email: [email protected]
Date: "09/20/2012"
Updates: Added FilterSID Parameter
Cleaned Up Code, defined fewer variables when creating PSObjects
ToDo: Clean up the UserSID Translation, to continue even if the SID is local
#>
[CmdletBinding()]
param(
[Parameter(Position=0,ValueFromPipeline=$true)]
[Alias("CN","Computer")]
[String[]]$ComputerName="$env:COMPUTERNAME",
[String]$FilterSID,
[String]$WQLFilter="NOT SID = 'S-1-5-18' AND NOT SID = 'S-1-5-19' AND NOT SID = 'S-1-5-20'"
Begin
#Adjusting ErrorActionPreference to stop on all errors
$TempErrAct = $ErrorActionPreference
$ErrorActionPreference = "Stop"
#Exclude Local System, Local Service & Network Service
}#End Begin Script Block
Process
Foreach ($Computer in $ComputerName)
$Computer = $Computer.ToUpper().Trim()
Try
#Querying Windows version to determine how to proceed.
$Win32OS = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Computer
$Build = $Win32OS.BuildNumber
#Win32_UserProfile exist on Windows Vista and above
If ($Build -ge 6001)
If ($FilterSID)
$WQLFilter = $WQLFilter + " AND NOT SID = `'$FilterSID`'"
}#End If ($FilterSID)
$Win32User = Get-WmiObject -Class Win32_UserProfile -Filter $WQLFilter -ComputerName $Computer
$LastUser = $Win32User | Sort-Object -Property LastUseTime -Descending | Select-Object -First 1
$Loaded = $LastUser.Loaded
$Script:Time = ([WMI]'').ConvertToDateTime($LastUser.LastUseTime)
#Convert SID to Account for friendly display
$Script:UserSID = New-Object System.Security.Principal.SecurityIdentifier($LastUser.SID)
$User = $Script:UserSID.Translate([System.Security.Principal.NTAccount])
}#End If ($Build -ge 6001)
If ($Build -le 6000)
If ($Build -eq 2195)
$SysDrv = $Win32OS.SystemDirectory.ToCharArray()[0] + ":"
}#End If ($Build -eq 2195)
Else
$SysDrv = $Win32OS.SystemDrive
}#End Else
$SysDrv = $SysDrv.Replace(":","$")
$Script:ProfLoc = "\\$Computer\$SysDrv\Documents and Settings"
$Profiles = Get-ChildItem -Path $Script:ProfLoc
$Script:NTUserDatLog = $Profiles | ForEach-Object -Process {$_.GetFiles("ntuser.dat.LOG")}
#Function to grab last profile data, used for allowing -FilterSID to function properly.
function GetLastProfData ($InstanceNumber)
$Script:LastProf = ($Script:NTUserDatLog | Sort-Object -Property LastWriteTime -Descending)[$InstanceNumber]
$Script:UserName = $Script:LastProf.DirectoryName.Replace("$Script:ProfLoc","").Trim("\").ToUpper()
$Script:Time = $Script:LastProf.LastAccessTime
#Getting the SID of the user from the file ACE to compare
$Script:Sddl = $Script:LastProf.GetAccessControl().Sddl
$Script:Sddl = $Script:Sddl.split("(") | Select-String -Pattern "[0-9]\)$" | Select-Object -First 1
#Formatting SID, assuming the 6th entry will be the users SID.
$Script:Sddl = $Script:Sddl.ToString().Split(";")[5].Trim(")")
#Convert Account to SID to detect if profile is loaded via the remote registry
$Script:TranSID = New-Object System.Security.Principal.NTAccount($Script:UserName)
$Script:UserSID = $Script:TranSID.Translate([System.Security.Principal.SecurityIdentifier])
}#End function GetLastProfData
GetLastProfData -InstanceNumber 0
#If the FilterSID equals the UserSID, rerun GetLastProfData and select the next instance
If ($Script:UserSID -eq $FilterSID)
GetLastProfData -InstanceNumber 1
}#End If ($Script:UserSID -eq $FilterSID)
#If the detected SID via Sddl matches the UserSID, then connect to the registry to detect currently loggedon.
If ($Script:Sddl -eq $Script:UserSID)
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]"Users",$Computer)
$Loaded = $Reg.GetSubKeyNames() -contains $Script:UserSID.Value
#Convert SID to Account for friendly display
$Script:UserSID = New-Object System.Security.Principal.SecurityIdentifier($Script:UserSID)
$User = $Script:UserSID.Translate([System.Security.Principal.NTAccount])
}#End If ($Script:Sddl -eq $Script:UserSID)
Else
$User = $Script:UserName
$Loaded = "Unknown"
}#End Else
}#End If ($Build -le 6000)
#Creating Custom PSObject For Output
New-Object -TypeName PSObject -Property @{
Computer=$Computer
User=$User
SID=$Script:UserSID
Time=$Script:Time
CurrentlyLoggedOn=$Loaded
} | Select-Object Computer, User, SID, Time, CurrentlyLoggedOn
}#End Try
Catch
If ($_.Exception.Message -Like "*Some or all identity references could not be translated*")
Write-Warning "Unable to Translate $Script:UserSID, try filtering the SID `nby using the -FilterSID parameter."
Write-Warning "It may be that $Script:UserSID is local to $Computer, Unable to translate remote SID"
Else
Write-Warning $_
}#End Catch
}#End Foreach ($Computer in $ComputerName)
}#End Process
End
#Resetting ErrorActionPref
$ErrorActionPreference = $TempErrAct
}#End End
}# End Function Get-LastLogonThis should work:
Get-LastLogon -Computername (Get-content .\Servers.txt) | Export-CSV .\Output.csv -NoTypeInformation
I just tested it on my test domain and it did the trick. -
Modify this script for Time, not Date?
I'm a complete newbie to scripting. And I thought HTML was tough to pick up!
I have this script-- apparently the only one I could find that comes close to what I need.
// get new Date object
var d = new Date();
// format to mm/dd/yyyy
var sDate = util.printd("mm/dd/yyyy", d);
// insert date into form field
this.getField("todaysDate").value = sDate;
I need a script to perform this exact same operation but with the current system time (or MDT, that's fine). I tried swapping out 'Date' for 'Time' but no go. Anybody can help?
Much appreciated...
-carrieAre you creating your form in Acrobat or LiveCycle Designer.
For Acrobat forms:
You can get a lot of different information from the date object by changing the format string for the 'util.printd' method. See the reference George Johnson links to for the format string values that can change the displayed value.
// get new Date object
var d = new Date();
// format to h:MM tt
var sDate = util.printd("h:MM tt", d);
// insert date into form field
this.getField("todaysDate").value = sDate;
h - hours without leading zero
MM - minutes with leading zero if necessary
tt - am or pm designator
For LiveCycle Designer you can select the 'Custom' form tab and then the 'Current Date' field. Now change the script to:
$.rawValue
= num2Time(time(), TimeFmt(1))
More information about the time format is the 'Scripting Reference' under LiveCycle Designer's 'Help' menu option. -
Modifying the script to include multiple domains
Hi,
The below script will start the servers by connecting to node manager for a particular domain. How can I modify the below script to include multiple servers which are from multiple domains.
from java.util import Properties
from java.io import FileInputStream
from java.io import File
from string import split
def carryFileProperties(serverName) :
print 'carrying properties of: ' + serverName
#properties file to be loaded
myProps = Properties()
#load properties file
myProps.load(FileInputStream(File(serverName)))
return myProps
def serversList(fileProperties):
print 'selecting servers from the properties'
servers = []
properties = fileProperties.propertyNames()
while properties.hasMoreElements():
key = properties.nextElement()
element = split(key, '_')
if element[0] == 'SERVER':
servers.append(key)
print'LIST OF servers to initialize'
for server in servers:
print 'Server ==>> ' + fileProperties.get(server)
return servers
def startInstance():
user = fileProperties.get('USER_ADM')
passwd = fileProperties.get('USER_ADM_PASSWD')
nmIP = fileProperties.get('NODEMANAGER_IP')
nmPort = fileProperties.get('NODEMANAGER_PORT')
domainName = fileProperties.get('DOMAIN_NAME')
domainDirectory = fileProperties.get('DOMAIN_DIRECTORY')
nmConnect(user,passwd, nmIP, nmPort, domainName, domainDirectory, 'plain', 'true')
for server in servers:
print 'requesting the server startup ' + fileProperties.get(server)
nmStart(fileProperties.get(server), domainDirectory)
fileProperties = carryFileProperties('servers.properties')
servers = serversList(fileProperties)
startInstance()
below is the properties file
NODEMANAGER_IP=localhost
NODEMANAGER_PORT=5559
DOMAIN_NAME=base_domain
DOMAIN_DIRECTORY=/opt/weblogic/base_domain/
USER_ADM=weblogic
USER_ADM_PASSWD=weblogic
SERVER_1=managedServer1
SERVER_2=managedServer2
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------I was able to answer myself
-
How do I edit this script (newbie)
Editing a script
I found a script that creates a reminder event based upon the birthdays of my contacts in Address Book. It looks forward one week at a time.
I'm not familiar with creating scripts. How would I edit this to do the following (if possible)
1- I set up a contact list in Address Book for only those people whose birthdays I want to be reminded of. Is it possible to have this script only look through this contact list, not every contact.
2- Can it also be set up to delete the previously set events (so that the only events that appear are the ones for the ensuing week)
3- Can it be set up to remind me of anniversaries also? How would I edit it? (I tried to find and replace the term birthday with anniversary, but all it did was notify me of forthcoming week's birthdays but called them anniversaries)
Thanks!
===============
birthdayAlert.scpt
User set variables
set numberDaysNotice to 1 -- how many days before the birthday to alert you, 0 is that day
set timeOfNotification to 5 -- the hour you want the notification
set selectedCalender to "Birthday Reminders" -- the calender in iCal you want to add the events to
Setup
set birthdayPeople to {}
set birthdayDates to {}
Get the current date & next week
set today to current date
set nextWeek to today + (60 * 60 * 24 * 7)
Loop through everyone in the Address Book
tell application "Address Book"
set peopleArray to the name of every person
repeat with i from 1 to count of peopleArray
set thisPerson to person i
set thisBirthday to birth date of thisPerson
Check if they've got a birthday entered on their card
if thisBirthday is not equal to (missing value) then
set year of thisBirthday to year of (current date) -- otherwise it uses their birth year
See if it's in the next week
if (thisBirthday is greater than today) and (thisBirthday is less than nextWeek) then
set thisBirthday_day to day of thisBirthday
set thisBirthday_month to month of thisBirthday
Add them to our list
set birthdayPeople to birthdayPeople & name of thisPerson
set birthdayDates to birthdayDates & birth date of thisPerson
end if
end if
end repeat
end tell
If we have birthday's go into iCal and add the alerts
if (count of birthdayPeople) is greater than 0 and ((count of birthdayPeople) is equal to (count of birthdayDates)) then
tell application "iCal"
tell calendar selectedCalender
repeat with i from 1 to count of birthdayPeople
set thisDate to item i of birthdayDates
set year of thisDate to year of today
set time of thisDate to (60 * 60) * timeOfNotification
set day of thisDate to (day of thisDate) - numberDaysNotice
set thisEvent to make new event at end with properties {description:"", summary:(item i of birthdayPeople) & "'s Birthday", location:"", start date:thisDate, end date:thisDate + 15 * minutes}
tell thisEvent
make new display alarm at end with properties {trigger interval:0}
end tell
end repeat
end tell
end tell
end if1- I set up a contact list in Address Book for only those people whose birthdays I want to be reminded of. Is it possible to have this script only look through this contact list, not every contact.
Sure - if you created a specific group of the people you want to track then just change the line:
set peopleArray to the name of every person
to:
set peopleArray to the name of every person of group "Birthdays"
(or whatever group name you used). You see, as written your script just grabs everyone's name as opposed to just the names of people in the specific group.
2- Can it also be set up to delete the previously set events (so that the only events that appear are the ones for the ensuing week)
Yes, but that's a little trickier since you need some way to denote which events are birthday events vs. other events from last week. If you're using a specific calendar for this then you could just delete existing events in that calendar, or you could implement a minor change to the way you create events - use the description to identify this is one of your auto-created birthday alarms:
set thisEvent to make new event at end with properties {description:"birthday", summary:(item i of birthdayPeople) & "'s Birthday", location:"", start date:thisDate, end date:thisDate + 15 * minutes}
So now the events will have a specific description, so it's easy to start your new script off with a line that deletes existing 'birthday" events, via:
tell application "iCal"
delete every event of calendar selectedCalendar whose description = "birthday"
end tell
(you can nix the '... whose description = "birthday"' element if you just want to delete all existing events in the calendar).
3- Can it be set up to remind me of anniversaries also? How would I edit it? (I tried to find and replace the term birthday with anniversary, but all it did was notify me of forthcoming week's birthdays but called them anniversaries)
Sure, that's because you specifically ask Address Book for birthdays:
set thisBirthday to birth date of thisPerson
To track anniversaries you need to ask Address Book for different data. This one's a little tricker since anniversaries are tracked via the custom date element, so you'd need something like:
set anniversaryList to {}
tell application "Address Book"
repeat with eachPerson in (get every person) -- add 'of group "anniversaries' if you use a specific group
repeat with eachDate in eachPerson's custom dates
if label of eachDate = "anniversary" then
-- this person has an Anniversary set, so add your code here to check if eachDate is in the next week if it is:
copy eachPerson to end of anniversaryList
end if
end repeat
end repeat
end tell
At the end of this you'll have a list of people whose anniversary is upcoming and you can duplicate your iCal code to add anniversary events in addition to birthdays. -
Hello
How can I modify this script to target all Users OU in one domain to move all disabled accounts from each Users OU to move to the Disabled Users OU?
Search-ADAccount –AccountDisabled –UsersOnly –SearchBase “OU=Users,OU=test,OU=domain,DC=domain,DC=com” | Move-ADObject –TargetPath “OU=Disabled Users,DC=domain,DC=com”
The above script will work for but only for one OU, I need it to target all OU=Users OU.
ThanksHi Rover,
I‘m writing to check if the suggestions were helpful, if you have any questions, please feel free to let me know.
If you have any feedback on our support, please click here.
Best Regards,
Anna
TechNet Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected] -
Hi all, so all my contacts started with "+1". The goal was to erase the "+" and just have all of them start with "1". However, I messed up royally. I ran the following script, which made all my contacts start with "1+1". :
tell application "Contacts"
repeat with eachPerson in people
repeat with eachNumber in phones of eachPerson
set theNum to (get value of eachNumber)
if (theNum starts with "1+") then
set value of eachNumber to "1" & theNum
end if
end repeat
end repeat
save
end tell
This is messed up in 2 ways. Firstly, I meant to write "+1" in the script, but instead I wrote "1+". Secondly, even if I had written "1+", it still wouldn't make sense, because I'd effectively be telling the program to just add "1" in front of what's already there, including the "+1".
Could someone please tell me how to modify this script to say:
If the contact starts with "1+1", then erase the "1+1". Then I would need another script to take all my numbers and add "1" in front of them.What you want to do is simply delete the first few characters from the phone number, yes?
How about something like this:
repeat with eachNumber in phones of eachPerson
set theNum to (get value of eachNumber) as string
if (theNum starts with "1+1") then
set myFixedNum to (characters 3 thru -1) of theNum
else if (theNum starts with "+1") then
set myFixedNum to (characters 2 thru -1) of theNum
end if
set value of eachNumber to (myFixedNum as string)
end repeat
That will take you from 1+1 or +1 to 1 in one easy step. -
Modify shell script for alerts...
Hello,
had a question with regards to a simple script i wrote...it take care of our every hour archive backup...NOT GOOD IN SHELL SCRIPTING....i get e-mail every single time its backed up.....i want this script to be modified in a way...where i get e-mail notification only and only if the backup fails for whatever reason...here is the script..can someone help me modifying this script....
export MMSG=/tmp/$$.mail
export ADDR="[email protected]"
export ORACLE_SID=test
export ORACLE_HOME=/u01/oracle/10g
rm -f $$MMSG > /dev/null 2>&1
echo "ARCHIVE BACKUP STARTED: "'date'
echo "ARCHIVE BACKUP STARTED: "'date' > $MMSG
/u01/oracle/10g/bin/rman target / @/home/oracle/scripts/archive_1.scr >> $MMSG 2>&1
echo "ARCHIVE BACKUP COMPLETED: "'date'
echo "ARCHIVE BACKUP COMPLETED: "'date' >> $MMSG
if [ -f $MMSG ]
then
mailx -s "Archive Backup Status" $ADDR < $MMSG
fi
rm -f $MMSG > /dev/null 2>&1
-------------------------------------------------------------------------------------------------------Try this:
export MMSG=/tmp/$$.mail
export ADDR="[email protected]"
export ORACLE_SID=test
export ORACLE_HOME=/u01/oracle/10g
rm -f $$MMSG > /dev/null 2>&1
echo "ARCHIVE BACKUP STARTED: "'date'
echo "ARCHIVE BACKUP STARTED: "'date' > $MMSG
/u01/oracle/10g/bin/rman target / @/home/oracle/scripts/archive_1.scr >> $MMSG 2>&1
rc=$?
if [ $rc -eq 0 ]
then
echo "ARCHIVE BACKUP COMPLETED: "'date'
echo "ARCHIVE BACKUP COMPLETED: "'date' >> $MMSG
else
echo "ARCHIVE BACKUP FAILED: "'date'
echo "ARCHIVE BACKUP FAILED: "'date' >> $MMSG
mailx -s "Archive Backup Status" $ADDR < $MMSG
fi -
Is possible to have a script that makes a text randomly have caps and lower caps... i would love to create a kind of effect so it would look like manuscript - but it cannot be only the same letter in caps or lower caps - I wOuld NeEd oF SOmeTHing LikE This (random) - is it possibel?
Hi,
Sample with 2 regex:
Launching the 1rst regex:
Launching the 2nd regex: -
Is it possible to create a script that does this?
Hey there,
I can work my way around a Mac pretty well, but as for coding, I'm not as good. Hopefully someone will know how to do what I'm looking for:
I do a lot of school assignments on my computer, and I've recently utilized an online service that allows me to sync up my files on my computer with their servers (like MobileMe, but not). Anyway, this is great and all, but this service is virtually useless if I'm trying to access a Pages publication via my school's computers which run Windows and, consequently, Microsoft Word 2007. However, they ALSO run Adobe Reader. Is it possible to create a script that, every time I save a Pages publication, automatically creates a PDF export of that same file in the directory where I'm working? Also, when I update the Pages file, it'll automatically update the PDF file?Saving a script as a Script, an Application or an Application bundle requires the use of the Script Editor as explained in the System (Finder) help.
step 1:
open the script in the Script Editor
step 2:
compile it clicking the "Compile" button
step 3:
Save the script from the "File > Save" menu:
To save as "script" select the "script" menu item
To save as "Application" select the "Application" menu item
To save as _"Application Bundle"_ select the _"Application Bundle"_ menu item
The files which I post are saved thru the "Text" menu item which attache the extension name ".applescript" telling that it's an _Applescript's text file._
All these infos are given in resources pointed by my late messages !
Now are infos which maybe you will not find in the Apple's resources
I use the text (.applescript" format because it embeds nothing related to my machine.
To work from the Scripts menu, my best choice is "Script" which appears to be the fastest one.
"Application" is slower and sometimes gives odd results on MacIntels.
"Application Bundle" behaves well on every machines but is slower than "Script".
Yvan KOENIG (from FRANCE vendredi 29 mai 2009 09:53:21) -
Adobe FP 10-A Script in this movie is causing Adobe FP 10 to run slowly. If it continues to run your computer may become unresponsive. Do you want to abort this script? yes or no. How do I fix this crash?
Hi,
Some "movies' are actually Flash files.
This means the Flash App will play them (possibly in a browser in some cases).
Depending where this item is and how it is playing it may be effected by other things
A web page can include javascript.
Apple uses javascript here to help with creating the posting box, the Edit options, Adding pics/smilies and the like.
Sometimes the javascript can be what is called a runaway process and gets sort of stuck in an endless loop.
If it is a free standing item then it might be triggered by AppleScript on the Mac. (or be modified in some way)
Again if the Script (normally written with a upper case S) is not perfect it can cause problems.
9:09 pm Wednesday; February 26, 2014
iMac 2.5Ghz 5i 2011 (Mavericks 10.9)
G4/1GhzDual MDD (Leopard 10.5.8)
MacBookPro 2Gb (Snow Leopard 10.6.8)
Mac OS X (10.6.8),
Couple of iPhones and an iPad -
LMS3.2: is it possible to modify timeout session
Hi,
On windows, is it possible to modify the default timeout session ?
What is the default value ?
Many thanks for your help,
Elisabethwhich timeout?? - I assume you are talking about the web server timeout !?
I found this in one of my notes I made years ago ...
... the entry is still there in LMS 4.1 so I believe it is still valid...
(I do not know if you have to restart dmgtd afterwards)
make a backup of the following file:
NMSROOT/MDC/tomcat/webapps/classic/WEB-INF/web.xml
open the file in a text editor and look for the tag below; the session-timeout is given in minutes (default: 2h);
keep in mind that changing the value has impact on the web server load (i.e. do not make it too long..)
the tag should be at the very end of the file:
120 -
Hi guys,
I have in my application a subvi which i use to save the configuration of application. I create one file with the last saved configuration, and i would like to open this values and that i could to modify this indicator value, but i cant since to modify i need 'numeric control' and to read the data from file i need 'numeric indicator '...
I thought, use a numeric control and use the values from file to the default values, but i didnt get to find the property node to adjust it. is it possible? or any different way to get it....??
Also, i attached the capture file.. i would like the program DOESNT SHOW the question of
replace the file!!. i would like directly replace the file when i push save.
Thanks, i attached the vi.
Attachments:
options.vi 43 KB
config.cnf 1 KB
capture.GIF 43 KBHi Dennis,
Your 'write to sreadshhet mod' suprime the dialog of replace file or not!, i want when i push save, it show the dialog input name of file and show the default sim000 but when i push this sim000 and this file already exist, then show the dialog to replace or not, if i replace Ok not problem, but when i push cancel replace it shows error eof!!!.
Your file, only remove this dialog and only replace the file directly.
i put the capture, when i choose the file to save and the program say to me this file exist and it give me the option of replace or not,i want when i push cancel replace it continues running without get error.
is it possible?.
Thanks.
Regards, Fonsi.
Attachments:
capture.GIF 71 KB
example.vi 40 KB -
Can someone help me modify a script file?
Hi Everyone!
I am working on a couple videos in AE that need subtitles.
I found this script that would work for me really well:
// Subtitle generator by !Rocky
// modified by Colin Harman ( http://colinharman.com/ ) to work on a Mac
// Save this code as
// "subtitles.jsx"
// Create a text file with your subtitles.
// Each line of text is one on-screen line.
// To have several lines on-screen at the same time,
// simply separate them with a pipe ( | ) character.
// eg "Character 1 talks|Character 2 interrupts"
// Create a new text layer in your comp, adjust its position,
// make sure the text's centered, so it looks nice
// Add markers (Numpad *) where each subtitle line must be shown/hidden.
// With the text layer selected, run the script, and select the subtitles file.
// Enjoy!
function makeSubs() {
var layer = app.project.activeItem.selectedLayers[0];
if (layer.property("sourceText") != null) {
var textFile = File.openDialog("Select a text file to open.", "");
if (textFile != null) {
var textLines = new Array();
textFile.open("r", "TEXT", "????");
while (!textFile.eof)
textLines[textLines.length] = textFile.readln();
textFile.close();
var sourceText = layer.property("sourceText");
var markers = layer.property("marker");
for (var i = sourceText.numKeys; i >= 1; i--)
sourceText.removeKey(i);
var line = 0;
var subTime, subText;
for (var i = 1; i <= markers.numKeys; i++) {
subTime = markers.keyTime(i);
sourceText.setValueAtTime(0, " ");
if ((i % 2) == 0) {
subText = " ";
else {
subText = textLines[line].replace("|", "\x0d\x0a");
line++;
sourceText.setValueAtTime(subTime, new TextDocument(subText));
makeSubs();
Except there is one problem. With this script, the first marker makes the first line show, the second marker makes the first line disappear and the third marker makes the second line show. (etc..)
Can this be modified in a way that the first marker would make the first line show, the second marker would make the second line show (etc..) As I don't need "empty" subtitles in this case.
Thanks,
DanielHi,
I get an error at line 50 but it seems to be working fine. I will test it on one of the videos later today.
Thanks for the help!
Maybe you are looking for
-
Ipod is not Recognized by Mac.
I have a third generation Ipod, it is three years old. I recently charged it with an outlet charger and not by my computer. Now the ipod says that i need to connect my Ipod to my computer to reset it, but when i connect it to my mac it doesn't recogn
-
I took some video over christmas using my iphone 4 and ever since i have been trying to back up these videos for safe keeping. When i tried to back up to my computer's c drive only the smallest file would load, the other 2 the icon would appear but
-
Dear All, May i know how to calcuate the moving average in B1? can i custom it or it is already set in the system that i cannot change it ? Many thanks!
-
Select between home and work addresses for Autofill
I've searched and browsed for this and I think I know the answer but I want to check before I submit a feature request to Apple and give up for now: Can we choose between home and work addresses on our contact card when we have Safari perform autofil
-
How do I sync and transfer contact GROUPS from yahoo address book to ipad "contacts". itunes will only let me transfer ALL contacts to "contacts"