Is this script ok
I set up two databases (10.2.0.4 on Windows 2003 64 bit server) and set up daily backups for both in dbconsole to keep a recovery window of two days. After awhile the backups just stopped working, and after spending too many hours of my time fiddling with dbconsole and still not getting it up and running, I'm ditching it altogether and am going to install the old java OEM or some 3rd party tool for monitoring, and script my backups and have task manager run them, at least I know they'll work this way..
Anyway, my recovery window is already configured in RMAN to 2 days, so I am thinking this script should do the trick. I have not done this manually before, so please point out anything incorrect.
backup.rcv:
run
backup database including archivelog;
crosscheck backup;
crosscheck archivelog all;
delete noprompt obsolete;
I am thinking since I have the flash recovery area, recovery window etc. already configured, there is no need to alllocate channels and/or define recovery window, am I correct in this?
My plan is to create an backup command called rmanback.cmd which will have the following in it, and have task manager run this nightly.
rman target / @backup.rcv
thanks in advance
Basically I am just replicating what I had running via dbconsole, it's not a huge or overly complex database so in this particular case just nightly full backups with archived logs backed up and a recovery window of two days is sufficient. I also run a user-managed backup script as well, the rman backup is for redundancy plus I use it to keep a larger recovery window if I ever need it and also keep the archive logs from filling the disk.
I find dbconsole overly complex and clunky to use, as well as unreliable so I just wanted to move my rman backup off of it and have it running independently.
Similar Messages
-
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. -
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; -
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. -
Can't figure out how to make this script work
Hey Folks,
Anyone here who would like to look at the following script and tell me where I made the error(s)?
I want to put this script in a Batch so that I can run it on a directory of files all with filenames like
Q-CAT 2010-01 Covers_v7bP01x.pdf and
Q-CAT 2010-01 Covers_v7bP02x.pdf
I put this script in the correct spot, but nothing happens... I tried the debugger console, and I get:
Begin Job Code
Processing File #1
State P01 detected
Batch aborted on run #1Error: NotAllowedError: Security settings prevent access to this property or method.
End Job Code
This is the script, it's supposed to run in Acrobat 9:
/* Q-CatCoverPagesSaveAs */
/* this script Crops CatCovers' Spreads and saves it into separate pages */
/* ©20100521 - AOP-Creatives, Willy Croezen */
// Begin Job
if ( typeof global.counter == "undefined" ) {
console.println("Begin Job Code");
global.counter = 0;
// insert beginJob code here
// Main Code to process each of the selected files
try {
global.counter++
console.println("Processing File #" + global.counter);
// insert batch code here.
function doCropPages()
this.setPageBoxes({
cBox: "Crop",
rBox: cropLeft
app.beginPriv();
console.println("Save LeftPageName");
// this.saveAs(this.path.slice(1, fname.indexOf(pageSide)) + leftPageName);
app.endPriv();
this.setPageBoxes({
cBox: "Crop",
rBox: cropRight
app.beginPriv();
console.println("Save RightPageName");
// this.saveAs(this.path.slice(1, fname.indexOf(pageSide)) + rightPageName);
app.endPriv();
//Declaration List
var Units = "mm";
var i = this.path.search(/[^:/]+\.pdf$/);
var fname = this.path.slice(i, this.path.length - 4);
var cropRect = this.getPageBox("Crop");
//Check if filename contains P01, indicating the Outside spread of a Catalog Cover. If so, crop accordingly
if (fname.indexOf("P01") != 0)
console.println("State P01 detected");
var pageSide = "P01";
var leftPageName = "P260.pdf";
var rightPageName = "P001.pdf";
var cropLeft = new Array();
cropLeft[0] = cropRect[0];
cropLeft[1] = cropRect[1];
cropLeft[2] = cropRect[2];
cropLeft[3] = cropRect[3] + 277.5;
var cropRight = new Array();
cropRight[0] = cropRect[0];
cropRight[1] = cropRect[1];
cropRight[2] = cropRect[2] + 223.5;
cropRight[3] = cropRect[3] - 62;
doCropPages();
else
//If filname does NOT contain P01, check if filename contains P02, indicating the Inside spread of a Catalog Cover. If so, crop accordingly
if (fname.indexOf("P02") != 0)
console.println("State P02 detected");
var pageSide = "P02";
var leftPageName = "P002.pdf";
var rightPageName = "P259.pdf";
var cropLeft = new Array();
cropLeft[0] = cropRect[0];
cropLeft[1] = cropRect[1];
cropLeft[2] = cropRect[2];
cropLeft[3] = cropRect[3] + 223.5;
var cropRight = new Array();
cropRight[0] = cropRect[0];
cropRight[1] = cropRect[1];
cropRight[2] = cropRect[2] + 277.5;
cropRight[3] = cropRect[3];
doCropPages();
else
// If filename doesn't contain P01 OR P02, give Error notice
console.println("Document is not correctly named! Should have P01 or P02 in it");
catch(e) {
console.println("Batch aborted on run #" + global.counter + "Error: " + e);
delete global.counter; // so we can try again, and avoid End Job code
event.rc = false; // abort batch
// End Job
if ( global.counter == global.FileCnt ) {
console.println("End Job Code");
// insert endJob code here
// may have to remove any global variables used in case user wants to run
// another batch sequence using the same variables, for example...
delete global.counter;Hy Folks,
This thread can be closed, as I fixed the script! It turned out that I needed to put the function definition above the body-code for the script to find it. After that it was small details.
I created a conversion variable (UnitsConv) for the margins so you can simply enter the desired dimensions in mm, instead of px, which I thought was easier.
This script now perfectly processes the files you put to it in a batch-operation (if correctly named with P01 and P02 in the filename.) and saves the resulting pages into the specified temp-directory. This time the filenames reflect the original filenames, for easy identification later, with the new pagenumbers appended to them.
For your information (and perhaps for use as the base for a custom script for yourself) I give you the final working version below.
This script will be trimmed down and become part of a larger script, or scriptset, which I will be using to automate the workflow of creating al different versions of lowres and highres catalogs that we need.
Kind regards,
Willy Croezen
/* Q-CatCoverPagesSaveAs v1.0*/
/* this script Crops CatCovers' Spreads and saves it into separate pages */
/* ©20100521 - AOP-Creatives, Willy Croezen */
// Begin Job
if ( typeof global.counter == "undefined" ) {
console.println("Begin Job Code ");
global.counter = 0;
// insert beginJob code here
// Main Code to process each of the selected files
try {
global.counter++
console.println("Processing File #" + global.counter);
// insert batch code here.
function doCropPages(crL,crR,lPName,rPName)
this.setPageBoxes({
cBox: "Crop",
rBox: crL
console.println("Save LeftPageName to: D:/temp/" + lPName);
this.saveAs("/D/temp/" + lPName);
this.setPageBoxes({
cBox: "Crop",
rBox: crR
console.println("Save RightPageName to: D:/temp/" + rPName);
this.saveAs("/D/temp/" + rPName);
//Declaration List
var UnitsConv = (72 / 25.4);
var i = this.path.search(/[^:/]+\.pdf$/);
var fname = this.path.slice(i, this.path.length - 4);
var cropRect = this.getPageBox("Crop");
//Check if filename contains P01, indicating the Outside spread of a Catalog Cover. If so, crop accordingly
if (fname.indexOf("P01") != -1)
console.println("Value fname.indexOf(P01) = " + fname.indexOf("P01"));
console.println("State P01 detected");
var pageSide = "P01";
var leftPageName = fname + "P260.pdf";
var rightPageName = fname + "P001.pdf";
// Create array of crop-values. Sequence is left, top, right, bottom
var cropLeft = new Array();
cropLeft[0] = cropRect[0];
cropLeft[1] = cropRect[1];
cropLeft[2] = cropRect[2] - Math.floor(277.5 * UnitsConv);
cropLeft[3] = cropRect[3];
var cropRight = new Array();
cropRight[0] = cropRect[0] + Math.floor(223.5 * UnitsConv);
cropRight[1] = cropRect[1];
cropRight[2] = cropRect[2] - Math.floor(62 * UnitsConv);
cropRight[3] = cropRect[3];
doCropPages(cropLeft,cropRight,leftPageName,rightPageName);
else
//If filname does NOT contain P01, check if filename contains P02, indicating the Inside spread of a Catalog Cover. If so, crop accordingly
if (fname.indexOf("P02") != -1)
console.println("State P02 detected");
var pageSide = "P02";
var leftPageName = fname + "P002.pdf";
var rightPageName = fname + "P259.pdf";
// Create array of crop-values. Sequence is left, top, right, bottom
var cropLeft = new Array();
cropLeft[0] = cropRect[0];
cropLeft[1] = cropRect[1];
cropLeft[2] = cropRect[2] - Math.floor(223.5 * UnitsConv);
cropLeft[3] = cropRect[3];
var cropRight = new Array();
cropRight[0] = cropRect[0] + Math.floor(277.5 * UnitsConv);
cropRight[1] = cropRect[1];
cropRight[2] = cropRect[2];
cropRight[3] = cropRect[3];
doCropPages(cropLeft,cropRight,leftPageName,rightPageName);
else
// If filename doesn't contain P01 OR P02, give Error notice
console.println("Document is not correctly named! Should have P01 or P02 in it");
catch(e) {
console.println("Batch aborted on run #" + global.counter + "Error: " + e);
delete global.counter; // so we can try again, and avoid End Job code
event.rc = false; // abort batch
// End Job
if ( global.counter == global.FileCnt ) {
console.println("End Job Code");
// insert endJob code here
// may have to remove any global variables used in case user wants to run
// another batch sequence using the same variables, for example...
delete global.counter; -
A couple of years ago I was using an AppleScript file (thanks to someone else's assistance) but it no longer works.
I have an extra internal drive, that is partitioned, and used for sequential daily backups. When the computer starts up, of course all the drives mount - but I prefer that they are off the desktop until neded.
Rather than selecting the volumes and then dragging to the Trash, I found it easier to have a script run at startup which then asks if the drives should be unmounted.
Things were great - until I upgraded to Tiger.
I am hoping that someone can tell me what's wrong with the script so that I can start using it again. As you can probably tell, I don't have any experience in AppleScript. At the moment the script runs - it presents the dialogue box - and then just ends after a response, but the drives do not unmount.
The partitions on the drive are called Monday Tuesday Wednesday Thursday Saturday
The existing script is as follows:
on run
display dialog "Unmount All Backup Drives?" buttons {"Yes", "No"} default button 1
set x to button returned of result
if x is "Yes" then tell application "Finder" to eject "Monday"
end runThis relates to another (current) thread in AppleScript discussions.
Your script works with Panther as that operating system allows INTERNAL drives to be "ejected" (and, if you eject one volume on a partitioned drive, all the volumes on that drive are ejected -- this explains why ejecting "Monday" actually ejected Monday through Friday).
With Tiger, you would find that your script works exactly as expected with EXTERNAL drives, but INTERNAL drives need a different approach.
To get behavior exactly as you had before, try this script:
--BEGINNING
display dialog "Unmount All Backup Drives?" buttons {"Yes", "No"} default button 1
set x to button returned of result
if x is "Yes" then set driveName to "Monday"
set driveInfo to do shell script "diskutil list | grep \"" & driveName & "\""
set driveID to last word of driveInfo
do shell script "diskutil unmountDisk " & driveID & ""
--END
For reasons that aren't entirely clear to me, this approach, while it works reliably, is very slow -- on my fast machine, the unmount process takes nearly 20 seconds. (Using UNIX directly in Terminal, with the same command, is very quick.) (In the AS, the delay occurs in second "do shell script.")
Another puzzle that has cropped up is described in the related thread "Applescript to Mount/Unmount a Disk . . ." (current). While the above approach works for Justin Surpless, it often prompts for a password -- unacceptable in his application. I've not seen this on my PPC (and I tried 10.4.7, which he's using); his may be an Intel Mac, if that could be the difference. -
Can i use this script in illustrator?
can i use this script in illustrator?
Newsgroup_User// This script exports extended layer.bounds information to [psd_file_name].xml
// by pattesdours
function docCheck() {
// ensure that there is at least one document open
if (!documents.length) {
alert('There are no documents open.');
return; // quit
docCheck();
var originalRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
var docRef = activeDocument;
var docWidth = docRef.width.value;
var docHeight = docRef.height.value;
var mySourceFilePath = activeDocument.fullName.path + "/";
// Code to get layer index / descriptor
cTID = function(s) { return app.charIDToTypeID(s); };
sTID = function(s) { return app.stringIDToTypeID(s); };
function getLayerDescriptor (doc, layer) {
var ref = new ActionReference();
ref.putEnumerated(cTID("Lyr "), cTID("Ordn"), cTID("Trgt"));
return executeActionGet(ref)
function getLayerID(doc, layer) {
var d = getLayerDescriptor(doc, layer);
return d.getInteger(cTID('LyrI'));
var stackorder = 0;
// function from Xbytor to traverse all layers
traverseLayers = function(doc, ftn, reverse) {
function _traverse(doc, layers, ftn, reverse) {
var ok = true;
for (var i = 1; i <= layers.length && ok != false; i++) {
var index = (reverse == true) ? layers.length-i : i - 1;
var layer = layers[index];
// alert("layer.typename >>> "+layer.typename );
if (layer.typename == "LayerSet") {
ok = _traverse(doc, layer.layers, ftn, reverse);
} else {
stackorder = stackorder + 1;
ok = ftn(doc, layer, stackorder);
return ok;
return _traverse(doc, doc.layers, ftn, reverse);
// create a string to hold the data
var str ="";
// class using a contructor
function cLayer(doc, layer) {
//this.layerID = Stdlib.getLayerID(doc, layer);
this.layerID = getLayerID(doc, layer);
//alert("layer ID: " + this.layerID);
this.layerWidth = layer.bounds[2].value - layer.bounds[0].value;
this.layerHeight = layer.bounds[3].value - layer.bounds[1].value;
// these return object coordinates relative to canvas
this.upperLeftX = layer.bounds[0].value;
this.upperLeftY = layer.bounds[1].value;
this.upperCenterX = this.layerWidth / 2 + layer.bounds[0].value;
this.upperCenterY = layer.bounds[1].value;
this.upperRightX = layer.bounds[2].value;
this.upperRightY = layer.bounds[1].value;
this.middleLeftX = layer.bounds[0].value;
this.middleLeftY = this.layerHeight / 2 + layer.bounds[1].value;
this.middleCenterX = this.layerWidth / 2 + layer.bounds[0].value;
this.middleCenterY = this.layerHeight / 2 + layer.bounds[1].value;
this.middleRightX = layer.bounds[2].value;
this.middleRightY = this.layerHeight / 2 + layer.bounds[1].value;
this.lowerLeftX = layer.bounds[0].value;
this.lowerLeftY = layer.bounds[3].value;
this.lowerCenterX = this.layerWidth / 2 + layer.bounds[0].value;
this.lowerCenterY = layer.bounds[3].value;
this.lowerRightX = layer.bounds[2].value;
this.lowerRightY = layer.bounds[3].value;
// I'm adding these for easier editing of flash symbol transformation point (outputs a 'x, y' format)
// because I like to assign shortcut keys that use the numeric pad keyboard, like such:
// 7 8 9
// 4 5 6
// 1 2 3
var windowW=2048;
var windowH=1536;
this.leftBottom = this.lowerLeftX + ", " + (windowH-this.lowerLeftY);
this.bottomCenter = this.lowerCenterX + ", " + (windowH-this.lowerCenterY);
this.rightBottom = this.lowerRightX + ", " + this.lowerRightY;
this.leftCenter = this.middleLeftX + ", " + this.middleLeftY;
this.center = this.middleCenterX + ", " + this.middleCenterY;
this.rightCenter = this.middleRightX + ", " + this.middleRightY;
this.leftTop = this.upperLeftX + ", " + this.upperLeftY;
this.topCenter = this.upperCenterX + ", " + this.upperCenterY;
this.rightTop = this.upperRightX + ", " + this.upperRightY;
// these return object coordinates relative to layer bounds
this.relUpperLeftX = layer.bounds[1].value - layer.bounds[1].value;
this.relUpperLeftY = layer.bounds[0].value - layer.bounds[0].value;
this.relUpperCenterX = this.layerWidth / 2;
this.relUpperCenterY = layer.bounds[0].value - layer.bounds[0].value;
this.relUpperRightX = this.layerWidth;
this.relUpperRightY = layer.bounds[0].value - layer.bounds[0].value;
this.relMiddleLeftX = layer.bounds[1].value - layer.bounds[1].value;
this.relMiddleLeftY = this.layerHeight / 2;
this.relMiddleCenterX = this.layerWidth / 2;
this.relMiddleCenterY = this.layerHeight / 2;
this.relMiddleRightX = this.layerWidth;
this.relMiddleRightY = this.layerHeight / 2;
this.relLowerLeftX = layer.bounds[1].value - layer.bounds[1].value;
this.relLowerLeftY = this.layerHeight;
this.relLowerCenterX = this.layerWidth / 2;
this.relLowerCenterY = this.layerHeight / 2;
this.relLowerRightY = this.layerHeight;
this.relLowerRightX = this.layerWidth;
this.relLowerRightY = this.layerHeight;
return this;
// add header line
str = "<psd filename=\"" + docRef.name + "\" path=\"" + mySourceFilePath + "\" width=\"" + docWidth + "\" height=\"" + docHeight + "\">\n";
// now a function to collect the data
var isParentAvailable=false;
var prevLayerSetName="";
function exportBounds(doc, layer, i) {
var isVisible = layer.visible;
var layerData = cLayer(doc, layer);
//alert("layer.name >>> "+layer.name );
//alert("typename >>> "+layer.typename);
/*if(layer.parent.name == "ParentTest"){
for(var i in layer.parent){
alert(" III >>> "+i+"<<<layer.parent>>"+layer.parent[i]);
if(isVisible){
// Layer object main coordinates relative to its active pixels
var startStr="";
if(layer.parent.typename=="LayerSet"){
if(prevLayerSetName!="LayerSet") {
startStr="\t<parentlayer id='"+layer.parent.name+"'>\n\t";
}else{
startStr="\t";
// endStr="\t</parentlayer>\n";
prevLayerSetName=layer.parent.typename;
}else{
if(prevLayerSetName=="LayerSet"){
startStr="\t</parentlayer>\n";
prevLayerSetName="";
var positionStr=layer.name.split(".")[0].substr(layer.name.split(".")[0].length-3,layer.name. split(".")[0].length);
var assetPosition=leftTop;
if(positionStr=="L_B"){
assetPosition=leftBottom;
}else if(positionStr=="B_C"){
assetPosition=bottomCenter;
}else if(positionStr=="R_B"){
assetPosition=rightBottom;
}else if(positionStr=="L_C"){
assetPosition=leftCenter;
}else if(positionStr=="C"){
assetPosition=center;
}else if(positionStr=="R_C"){
assetPosition=rightCenter;
}else if(positionStr=="L_T"){
assetPosition=leftTop;
}else if(positionStr=="T_C"){
assetPosition=topCenter;
}else if(positionStr=="R_T"){
assetPosition=rightTop;
var str2 =startStr+ "\t<layer name=\"" + layer.name
+ "\" stack=\"" + (i - 1) // order in which layers are stacked, starting with zero for the bottom-most layer
+ "\" position=\"" + assetPosition // this is the
+ "\" layerwidth=\"" + layerData.layerWidth
+ "\" layerheight=\"" + layerData.layerHeight
+ "\" transformpoint=\"" + "center" + "\">" // hard-coding 'center' as the default transformation point
+ layer.name + ".png" + "</layer>\n" // I have to put some content here otherwise sometimes tags are ignored
str += str2.toString();
// call X's function using the one above
traverseLayers(app.activeDocument, exportBounds, true);
// Use this to export XML file to same directory where PSD file is located
var mySourceFilePath = activeDocument.fullName.path + "/";
// create a reference to a file for output
var csvFile = new File(mySourceFilePath.toString().match(/([^\.]+)/)[1] + app.activeDocument.name.match(/([^\.]+)/)[1] + ".xml");
// open the file, write the data, then close the file
csvFile.open('w');
csvFile.writeln(str + "</psd>");
csvFile.close();
preferences.rulerUnits = originalRulerUnits;
// Confirm that operation has completed
alert("Operation Complete!" + "\n" + "Layer coordinates were successfully exported to:" + "\n" + "\n" + mySourceFilePath.toString().match(/([^\.]+)/)[1] + app.activeDocument.name.match(/([^\.]+)/)[1] + ".xml"); -
When I run this script nothing is output to the screen or spooled to a file
When I run this script nothing is output to the screen or spooled to a file. What do I need to do to get output from this script.
SET SERVEROUTPUT ON size 100000
DECLARE
v_schema Varchar2(50);
v_statement Varchar2(500);
v_name varchar2(30);
v_id varchar2(8);
v_pwd varchar2(16);
v_acct varchar2(16);
CURSOR get_schemas IS
SELECT DISTINCT owner
FROM all_tables
WHERE table_name = 'USERID'
ORDER BY owner;
BEGIN
OPEN get_schemas;
LOOP
FETCH get_schemas INTO v_schema;
EXIT WHEN get_schemas%NOTFOUND;
v_statement := 'SELECT name,usid,passwd,acctnum INTO v_name,v_id,v_pwd,v_acct FROM '||v_schema||'.userid';
execute immediate v_statement;
DBMS_OUTPUT.PUT_LINE('Name='||v_name||' ID='||v_id||' PW='||v_pwd||' AC='||v_acct);
END LOOP;
CLOSE get_schemas;
END;
/Do I include several variables after the INTO or just
one?
How do I loop through the record and print the
individual variables?
I appreciate your assistance!He already gave you the answer above:
v_statement := 'SELECT name,usid,passwd,acctnum FROM ' || v_schema ||
'.userid';
execute immediate v_statement
INTO v_name, v_id, v_pwd, v_acct;
If this is not printing any output, it is because you don't have a table named USERID... what are you trying to do? -
Only the last account is created when using this script in combination with a CSV
Hi, I've got a weird problem when using this script:
$Users = Import-Csv -Delimiter ";" -Path "......csv"
FOREACH ($User in $UserList) { $ User }
$OU = $User.path
$UPN = $User.UPN
$Password = $User.password
$Detailedname = $User.firstname + " " + $User.Lastname
$UserFirstname = $User.Firstname
$FirstLetterFirstname = $UserFirstname.substring(0,1)
$SAM = $User.UPN
$Company = $User.company
$Description = $User.description
$AccountExpirationDate = $User.accountexpirationdate
$params = @{ 'Name'=$Detailedname;
'SamAccountName'=$SAM;
'UserPrincipalName'=$SAM;
'DisplayName'=$Detailedname;
'GivenName'=$UserFirstname;
'Surname'=$User.Lastname;
'AccountPassword'=(ConvertTo-SecureString $Password -AsPlainText -Force);
'Enabled'=$True;
'PasswordNeverExpires'=$True;
'Path'=$OU;
'Company'=$Company;
'Description'=$Description;
'AccountExpirationDate'=$AccountExpirationDate }
New-ADUser @params
The CSV file has columns with the name: Lastname;Firstname;Password;Company;Description;UPN;path;AccountExpirationDate
Script runs without errors, but only creates the last line in the CSV file. Anyone that can help me, of put me in the right direction? Should be great!
Michiel
the NetherlandsHi Michiel,
You'll need to move $params and New-ADUser up into the foreach loop.
EDIT: Also, remove the { $ User } that you have next to the foreach loop. You're also using $Users instead of $UserList.
EDIT2: Here's a cleaned up version:
$UserList = Import-Csv -Delimiter ";" -Path "......csv"
FOREACH ($User in $UserList) {
$OU = $User.path
$UPN = $User.UPN
$Password = $User.password
$Detailedname = $User.firstname + " " + $User.Lastname
$UserFirstname = $User.Firstname
$FirstLetterFirstname = $UserFirstname.substring(0,1)
$SAM = $User.UPN
$Company = $User.company
$Description = $User.description
$AccountExpirationDate = $User.accountexpirationdate
$params = @{ 'Name'=$Detailedname;
'SamAccountName'=$SAM;
'UserPrincipalName'=$SAM;
'DisplayName'=$Detailedname;
'GivenName'=$UserFirstname;
'Surname'=$User.Lastname;
'AccountPassword'=(ConvertTo-SecureString $Password -AsPlainText -Force);
'Enabled'=$True;
'PasswordNeverExpires'=$True;
'Path'=$OU;
'Company'=$Company;
'Description'=$Description;
'AccountExpirationDate'=$AccountExpirationDate
New-ADUser @params
Don't retire TechNet! -
(Don't give up yet - 13,085+ strong and growing) -
This script is not checking the existing of the new created item
Dear Friends
I have This script is not checking the existing of the new created item I am using this script in side WHEN-BUTTON-PRESSED trigger
I am using oracle Forms [32 Bit] Version 6.0.8.11.3 (Production)
My script as the following :
BEGIN
BEGIN
SELECT ITEM_CODE INTO :GLOBAL.DUMMY
FROM IM_INVENTORY
WHERE ITEM_CLASS = TO_NUMBER(RTRIM(LTRIM(:IM_NEW_ITEMS.ITEM_CLASS)))
AND ITEM_TYPE = TO_NUMBER(RTRIM(LTRIM(:IM_NEW_ITEMS.ITEM_TYPE)))
AND ITEM_LENGTH = :IM_NEW_ITEMS.ITEM_LENGTH
AND ITEM_WIDTH = :IM_NEW_ITEMS.ITEM_WIDTH
AND ITEM_HIGHT1 = :IM_NEW_ITEMS.ITEM_HIGHT1
AND ITEM_HIGHT2 = :IM_NEW_ITEMS.ITEM_HIGHT2
AND COLOR_CODE = TO_NUMBER(RTRIM(LTRIM(:IM_NEW_ITEMS.COLOR_CODE)))
AND SHAPE_CODE = TO_NUMBER(RTRIM(LTRIM(:IM_NEW_ITEMS.SHAPE_CODE)));
-- get_err_message(87);
SHOW_MESSAGE('This Item Already Exist !!!');
RAISE FORM_TRIGGER_FAILURE;
EXCEPTION
WHEN NO_DATA_FOUND THEN
show_message('here');
INSERT INTO IM_INVENTORY
(ITEM_CODE,ITEM_NAME_A,ITEM_NAME_E,STOCK_ITEM,ITEM_CLASS,ITEM_TYPE,SUPP_CODE,ITEM_LENGTH,ITEM_WIDTH,
ITEM_HIGHT1,ITEM_HIGHT2,COLOR_CODE,SHAPE_CODE,ITEM_SIZE_TYPE,VOLUME,CON_FACTOR,ITEM_PRICE1,
ITEM_DISCOUNT,MIN_QTY,MAX_QTY,COSTING_METHOD,ITEM_COST,STANDARD_COST,WEIGHT,ITEM_PRICE2,ITEM_PRICE3,
OPENING_COST,LAST_PUR_COST,QTY_FOR_PRICE2,QTY_FOR_PRICE3,ITEM_PRICE_METHOD,USER_ID,USER_DATE)
VALUES(:IM_NEW_ITEMS.ITEM_CODE,:GLOBAL.LOC_VAR_A,:GLOBAL.LOC_VAR_E,'1',:IM_NEW_ITEMS.ITEM_CLASS,:IM_NEW_ITEMS.ITEM_TYPE,'0',
:IM_NEW_ITEMS.ITEM_LENGTH,:IM_NEW_ITEMS.ITEM_WIDTH,:IM_NEW_ITEMS.ITEM_HIGHT1,:IM_NEW_ITEMS.ITEM_HIGHT2,
NVL(:IM_NEW_ITEMS.COLOR_CODE,0),NVL(:IM_NEW_ITEMS.SHAPE_CODE,0),1,NVL(:IM_NEW_ITEMS.VOLUME,0),1,:GLOBAL.ITEM_PRICE1,0.00,0.00,0.00,'1',0.00,0.00,
0.00,:GLOBAL.ITEM_PRICE1,:GLOBAL.ITEM_PRICE1,0.000,0.000,0.000,0.000,1,:IM_NEW_ITEMS.USER_ID,:IM_NEW_ITEMS.USER_DATE);
standard.commit; -- NEW COMMITED
clear_message; -- NEW COMMITED
WHEN FORM_TRIGGER_FAILURE THEN
SHOW_MESSAGE('Error : '||SQLERRM);
RAISE FORM_TRIGGER_FAILURE ;
WHEN OTHERS THEN
SHOW_MESSAGE('Error : '||SQLERRM);
RAISE FORM_TRIGGER_FAILURE ;
END;
END;
Waiting for your valuable answer .
Best regards
Jamil AlshaibaniHi,
I have written the script also with constants values but still it is not going to
SHOW_MESSAGE('This Item Already Exist !!!');
and the script is written as the following :
BEGIN
SELECT 1 INTO :GLOBAL.DUMMY
FROM IM_INVENTORY
WHERE ITEM_CLASS ='110'
AND ITEM_TYPE ='110105'
AND ITEM_LENGTH = 1
AND ITEM_WIDTH = 1
AND ITEM_HIGHT1 = 1
AND ITEM_HIGHT2 = 0
AND COLOR_CODE = '3001'
AND SHAPE_CODE = '201' ;
SHOW_MESSAGE('1- This Item Already Exist !!!');
RAISE FORM_TRIGGER_FAILURE;
EXCEPTION
WHEN NO_DATA_FOUND THEN
show_message('here');
INSERT INTO IM_INVENTORY
(ITEM_CODE,ITEM_NAME_A,ITEM_NAME_E,STOCK_ITEM,ITEM_CLASS,ITEM_TYPE,SUPP_CODE,ITEM_LENGTH,ITEM_WIDTH,
ITEM_HIGHT1,ITEM_HIGHT2,COLOR_CODE,SHAPE_CODE,ITEM_SIZE_TYPE,VOLUME,CON_FACTOR,ITEM_PRICE1,
ITEM_DISCOUNT,MIN_QTY,MAX_QTY,COSTING_METHOD,ITEM_COST,STANDARD_COST,WEIGHT,ITEM_PRICE2,ITEM_PRICE3,
OPENING_COST,LAST_PUR_COST,QTY_FOR_PRICE2,QTY_FOR_PRICE3,ITEM_PRICE_METHOD,USER_ID,USER_DATE)
VALUES(:IM_NEW_ITEMS.ITEM_CODE,:GLOBAL.LOC_VAR_A,:GLOBAL.LOC_VAR_E,'1',:IM_NEW_ITEMS.ITEM_CLASS,:IM_NEW_ITEMS.ITEM_TYPE,'0',
:IM_NEW_ITEMS.ITEM_LENGTH,:IM_NEW_ITEMS.ITEM_WIDTH,:IM_NEW_ITEMS.ITEM_HIGHT1,:IM_NEW_ITEMS.ITEM_HIGHT2,
NVL(:IM_NEW_ITEMS.COLOR_CODE,0),NVL(:IM_NEW_ITEMS.SHAPE_CODE,0),1,NVL(:IM_NEW_ITEMS.VOLUME,0),1,:GLOBAL.ITEM_PRICE1,0.00,0.00,0.00,'1',0.00,0.00,
0.00,:GLOBAL.ITEM_PRICE1,:GLOBAL.ITEM_PRICE1,0.000,0.000,0.000,0.000,1,:IM_NEW_ITEMS.USER_ID,:IM_NEW_ITEMS.USER_DATE);
standard.commit; -- NEW COMMITED
clear_message; -- NEW COMMITED
WHEN FORM_TRIGGER_FAILURE THEN
SHOW_MESSAGE('Error : '||SQLERRM);
RAISE FORM_TRIGGER_FAILURE ;
WHEN OTHERS THEN
SHOW_MESSAGE('Error : '||SQLERRM);
RAISE FORM_TRIGGER_FAILURE ;
END;
Best regards
Jamil -
Getting the name of the Action that runs this script
If I create a action in photoshop to run a script called "test script", How can I determine within the "test script" what action name started running this script? I'm trying to write a script to scale my images. The scaling will be determined by what Action ran this script.
Example
Action Names are 5x7, 4x6, 8x10
Eash action above will run the same script called "scale me"
Within "scale me", the java code will determine that 4x6 started running "scale me"
"scale me" will go to the section within the java code to scale the image loaded in Photoshop to a 4x6 size.
The reason for writing the "scale me" code this way is that I can maintain only one script to scale my images.
Any suggestions or help would be appreciated.
RaymondThanks for all your comments. Micheal, I took your code for the "ActionReference()" object and it works great! I completed my code and it is working okay (some more testing needed).
* My Scaling Impage Script */
var docRef = app.activeDocument; //Pointer to current opened document
finish:
if (documents.length == 0) // Check to see if image opened if not, error message
alert('There are no opened images\r\r' +"Exiting Script");
break finish;
var savedState = docRef.activeHistoryState // Save the history state
var originalUnit = preferences.rulerUnits // Save the existing ruler perferences - units
var ref = new ActionReference(); //Pointer to current selected Action
ref.putEnumerated( charIDToTypeID("Actn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); // Point to selected Action
var desc = executeActionGet(ref);
var actionName = desc.getString( charIDToTypeID("Nm ") ); // Get Name of seclected Action
var actionSetName = desc.getString( charIDToTypeID("PrNm") ); // Get Group the selected Action belongs to
var actionnumber = 100; //actionname = 100 (No Action Defined as default)
var portraitorienation = 0; // Orientation default to portrait
var resolutions = 300; // resolution default to 300
var sizeh = 999999; // default size
var sizew = 999999; // default size
var resolution = 300;
var scaleup1 = 0; //enlargement
var scaleup2 = 0; //enlargement
var scaleflag = 0;
var scaleflagg = 0
// Assumption is the long side is always defined in sizeh
if (actionName=="4 x 5") { actionnumber =0; sizeh = 1535; sizew = 1228;}
if (actionName=="4 x 6") { actionnumber =1; sizeh = 1842; sizew = 1228;}
if (actionName=="5 x 7") { actionnumber =2; sizeh = 2149; sizew = 1535;}
if (actionName=="6 x 9") { actionnumber =3; sizeh = 2127; sizew = 1842;}
if (actionName=="8 x 10") { actionnumber =4; sizeh = 3020; sizew = 2416;}
if (actionName=="8 x 12") { actionnumber =5; sizeh = 3624; sizew = 2416;}
if (actionName=="11 x 14") { actionnumber =6; sizeh = 4228; sizew = 3322;}
if (actionName=="12 x 18") { actionnumber =7; sizeh = 5436; sizew = 3624;}
if (actionName=="12 x 24") { actionnumber =8; sizeh = 7248; sizew = 3624;}
if (actionName=="12 x 36") { actionnumber =9; sizeh = 10872; sizew = 3624;}
preferences.rulerUnits = Units.PIXELS
var doch = parseInt (docRef.height);
var docw = parseInt (docRef.width);
scaleflag = doch-docw;
if ( doch > docw ) { scaleflagg =1}
if (scaleflagg == 0)
portraitorienation = 1; // Landscape Orientation
//alert("Seclected Landscape")
//alert(doch+" Height" +docw +" Width")
var scale1 = docw - sizeh
var scale2 = doch - sizeh
if (docw > sizeh) {scaleup1=1}
if (doch > sizeh) {scaleup2=1}
// We know know what action was started (What size to scale to and the orientation - Landscape or Portrait)
// alert ( "Current selected action is: "+actionName+"\r\rin the action set: "+actionSetName +"\r\rAction Number is " +actionnumber +"\r\rDeminsions are (HxW): " +sizeh +", "+sizew );
if (portraitorienation == 1) //landscape if true
if (scaleup1 == 1)
alert ( "This Photo is landscape\r\r"+ "The doc H x W are: " +doch +" x " + docw +"\r\r" +"Resizing to (H X W: " +sizew +", "+ sizeh + "\r\r" + "Reduction");
docRef.resizeImage (sizeh, undefined, resolution, ResampleMethod.BICUBICSHARPER) // Reduction in size
else
alert ( "This Photo is landscape\r\r"+ "The doc H x W are: " +doch +" x " + docw +"\r\r" +"Resizing to (H X W: " +sizew +", "+ sizeh + "\r\r" + "Enlargement");
docRef.resizeImage (sizeh, undefined, resolution, ResampleMethod.BICUBICSMOOTHER) //Enlargement in size
else // portrait
if (scaleup2 ==1)
alert ( "This Photo is Portrait\r\r"+ "The doc H x W are: " +doch +" x " + docw +"\r\r" +"Resizing to (H X W: " +sizeh +", "+ sizew + "\r\r" + "Reduction");
docRef.resizeImage (undefined, sizeh, resolution, ResampleMethod.BICUBICSHARPER)
else
alert ( "This Photo is Portrait\r\r"+ "The doc H x W are: " +doch +" x " + docw +"\r\r" +"Resizing to (H X W: " +sizeh +", "+ sizew + "\r\r" + "Enlargement");
docRef.resizeImage (undefined, sizeh, resolution, ResampleMethod.BICUBICSMOOTHER)
preferences.rulerUnits = originalUnit // Restore ruler perferences - units
My script is a single file that is run by the Actions, I've created for each size and each action runs the same script. When the script runs, it determines via "ActionReference();" what the current selected Action name is and then applies the scaling. This script has logic for landscape and portrait and will scale using the different algorithms (bicubic xxxx) depending if it is reducing the image or enlarging. The parametersfor the scaling is long side and constraint proportions.
So if I have to add another size to the code, all I need to do is to add one line of code to the script, copy any of the existing Actions and rename the copied Action to the size and I am done.
I'm not a experience programmer so pls don't laugh at my coding but have done some C, C++, Fortran (Yes I'm an electrical engineer) in my days. A number of things has stumped me abit and one of them was the use of arrays which didn't work for me too well. I was to use the array for storing my parameters of each size. Another one that really got me puzzled was the use of the docRef = activeDocument object. The docRef.height and docRef.width will tell you the dimensions of the document based on the units set for rules. I set mine for pixels. The problem I had was the statement if(docRef.height > docRef.width) { do some stufff}. If I change the > to < for the same document it alway gives me a "true" logical. After some thoughts today, I suspect that true is anything not 0 and false is only 0. I will try this out tonight. This theory does not fit well with my understanding on how the if statement works in other languages. Any comments on this would be appreciated.
Oh and I noticed some extra code var declarations that is not needed such as the activeHistoryState - was determining if I need to use this or the perferences.rulerunits to restore my ruler perferences and apparently the activeHistoryState does not and forgot to remove from the code. -
How best can i optimise this script
I have a script the loops through a table and function. it works fine but it takes a longer time complete even though resources are given. the code below is just the same code i used how best can i represent it for speed even though i have all resources.
For each_member in ( select from MemberTable where MemberID = 'ALL')*
Loop
Begin
if Age >= 18 then
hold:= 'Adult'
end if;
For Each_history in (select Acct,fx_function(each_member.ID,each_member.Acct) BR,
Movement from History a where history_ID =each_member.Id)
loop
Begin
insert into NewFilteredData (act,BR,mvt)
values (Each_history.Acct,Each_history.BR,Each_history.Movement);
end loop;
end loop;
end loop;
commit;
How best can i optimize this script to move data faster because they are a lot about 6000000 records to be moved.
please help.
Edited by: kama021 on Aug 25, 2009 12:48 PM
Edited by: kama021 on Aug 25, 2009 12:48 PMUnless something is horribly wrong (i.e. the optimizer picks a radically incorrect plan), if you can do something in SQL, it will always be faster to do it in SQL. Doing things in PL/SQL, particularly using cursor FOR loops and single row inserts, is the slowest possible way to do anything (well, other than having nested FOR loops).
Long before you start looking at things like the APPEND hint, I would focus on implementing a single SQL statement that generates the correct results. Once you have that and you have a benchmark, you can decide whether it is "fast enough". If it is (and I suspect it will be), you don't have to delve any deeper. If you need more performance, you can start looking into parallelism, the APPEND hint, etc. but be aware that this generally increases the complexity of the system.
Justin -
[Solved] Could someone that knows awk good fix this script for me?
I found this script on the linuxquestions site that tests and displays network bandwidth. There's an error in the script though and my awk experience isn't enough to debug it and is giving me the error:
awk: cmd. line:10: printf ("%4.0f", Ratio)}
awk: cmd. line:10: ^ syntax error
awk: cmd. line:10: printf ("%4.0f", Ratio)}
awk: cmd. line:10: ^ syntax error
^C/home/todd/.bin/bandwidth-test: line 21: [: : integer expression expected
BW Surchargé - Moyenne de de Kb/sec pendant 20 secondes
This is the script:
#!/bin/bash
# bandwidth-test - test bandwidth from the command line
Fic_Tmp="/tmp/Fic_Tmp_VerifRatio.tmp"
NbrSec=20
/usr/bin/bwm-ng -I eth0 -o csv -T avg -C " " -c ${NbrSec} | awk '
BEGIN{
BytesS=0
NbrLecture=0}
/eth0/&&NR>2{
BytesS+=$5/1024
NbrLecture+=1}
END{
Ratio=BytesS/NbrLecture
printf ("%4.0f", Ratio)}' > ${Fic_Tmp}
Ratio=$(cat ${Fic_Tmp})
rm ${Fic_Tmp}
if [ "${Ratio}" -lt 110 ];then
echo "BW OK - Moyenne de ${Ratio} de Kb/sec pendant ${NbrSec} secondes"
exit 0
else
echo "BW Surchargé - Moyenne de ${Ratio} de Kb/sec pendant ${NbrSec} secondes"
exit 2
fi
exit $?
Anyone available to fix this for me?
Last edited by Gen2ly (2009-11-17 17:52:14)Ah, thought I counted all those. Whoops . Yep that did the trick. Thanks benob.
Edit: Just FYI to any that read this. This script only checks if you are in the cap range, so it's not really a bandwidth tester for the command line. The nearest I've found is 'iperf' which I'm unable to get to use yet.
Edit2 : netperf seems better suited for this, only been able to learn how to do download speed test so far:
netperf -c hostname -f K
Last edited by Gen2ly (2009-11-17 19:08:38) -
This script is not updating or returning anything..
This script is not updating or returning anything.. Ive also tried running it as a Stored Procedure but didnt get very far..
I'm reluctant to remove the line from the get_employee cursor that gets only one record..
Also, Ive got a couple of 'dbms_output..' lines to catch the employee number but nothing. Can anyone suggest how I at least debug it?
I can also supply it as Stored Procedure but I didnt really know how to run it and it just hung in UNIX at what looked at the last line number..
here's the code
/* Formatted on 2009/04/22 14:43 (Formatter Plus v4.8.7) */
SET serveroutput ON SIZE 1000000 FORMAT WRAPPED
SET verify OFF
SET feedback OFF
DECLARE
-- Debugging/error handling
-- Work variables
p_emp_number VARCHAR2 (14);
v_rec_cnt NUMBER := 0;
insert_flag VARCHAR2 (8);
job_exists VARCHAR2 (8);
err_num NUMBER;
err_msg VARCHAR2 (150);
err_line VARCHAR2 (350);
err_seq NUMBER := 0;
l_date DATE := SYSDATE;
l_validate BOOLEAN DEFAULT FALSE;
l_ass_obj NUMBER;
l_emp_obj NUMBER;
l_default_code_comb_id NUMBER := 217269;
l_datetrack_update_mode VARCHAR2 (30) := 'CORRECTION';
l_organization_id NUMBER := 0;
l_concatenated_segments VARCHAR2 (240);
l_soft_coding_keyflex_id NUMBER;
l_comment_id NUMBER;
l_effective_end_date DATE
:= TO_DATE ('17-FEB-2059', 'DD-MON-YYYY');
l_no_managers_warning BOOLEAN;
l_special_ceiling_step_id NUMBER;
l_people_group_id NUMBER;
l_group_name VARCHAR2 (30);
l_entries_changed_warning VARCHAR2 (30);
l_spp_delete_warning BOOLEAN;
l_org_now_no_manager_warning BOOLEAN;
l_tax_district_changed_warning BOOLEAN;
l_other_manager_warning BOOLEAN;
l_business_group_id NUMBER := 0;
l_person_id NUMBER;
l_assignment_number VARCHAR2 (35);
l_style VARCHAR2 (4) := 'GB';
ip_p_address_id NUMBER;
l_effective_date DATE := SYSDATE;
l_date_from DATE := SYSDATE;
l_date_to DATE := NULL;
-- CURSOR 1 - get all Existing Employees (well, for testing purps.. just Peter Barlow for now..)
CURSOR c_get_employee_details
IS
SELECT DISTINCT per.person_id, per.employee_number, per.full_name,
paas.assignment_id, paas.supervisor_id,
paas.default_code_comb_id
FROM per_all_people_f per, per_all_assignments_f paas
WHERE per.employee_number = p_emp_number
AND paas.person_id(+) = per.person_id
AND per.person_id = '30188';
-- CURSOR 2 - get all Existing Employees (well, for testing purps.. just Peter Barlow for now..)
CURSOR c_check_employee (p_emp_number VARCHAR2)
IS
SELECT DISTINCT per.person_id, per.employee_number, per.full_name,
paas.assignment_id, paas.supervisor_id,
paas.default_code_comb_id
FROM per_all_people_f per, per_all_assignments_f paas
WHERE per.employee_number = p_emp_number
AND paas.person_id(+) = per.person_id
AND per.person_id = '30188';
emp_rec c_check_employee%ROWTYPE;
-- Cursor 3 to SELECT all existing Employees that DO NOT have a JOB specified.
/* CURSOR c_check_emps_job (p_emp_number VARCHAR2)
IS
SELECT DISTINCT per.person_id, per.full_name, paas.assignment_id,
paas.supervisor_id, paas.default_code_comb_id
FROM per_all_people_f per, per_all_assignments_f paas
WHERE per.employee_number = p_emp_number
AND paas.person_id(+) = per.person_id
AND paas.job_id IS NULL
AND per.person_id = '30188';
empjob_rec c_check_emps_job%ROWTYPE;
-- Cursor 4 retrieves latest Object Version Number from per_assignments_f table..
CURSOR csr_ass_ovn (cp_person_id IN per_all_people_f.person_id%TYPE)
IS
SELECT MAX (paas.object_version_number)
FROM per_assignments_f paas, per_all_people_f per
WHERE paas.person_id = per.person_id
AND per.employee_number = paas.assignment_number
AND per.person_id = cp_person_id;
BEGIN
-- UPDATE of EXISTING Employees Details from work table..
FOR v_emp IN c_get_employee_details
LOOP
-- determine whether customer already exists
OPEN c_check_employee (v_emp.employee_number);
FETCH c_check_employee
INTO emp_rec;
IF c_check_employee%FOUND
THEN
insert_flag := 'I';
DBMS_OUTPUT.PUT_LINE ('Employee No: ' || v_emp.employee_number);
ELSE
DBMS_OUTPUT.PUT_LINE ( 'Employee No: '
|| v_emp.employee_number
|| ' has not been found! '
insert_flag := 'X';
END IF;
CLOSE c_check_employee;
-- determine which customers already have been assigned a Job
/* OPEN c_check_emps_job (v_emp.employee_number);
FETCH c_check_emps_job
INTO empjob_rec;
IF c_check_emps_job%FOUND
THEN job_exists := 'X'; -- so we're wanting all those with job_exists := 'X'..
ELSE job_exists := 'I';
END IF;
CLOSE c_check_employee;
-- Obtain the most recent Object Version Number..
OPEN csr_ass_ovn (v_emp.person_id);
FETCH csr_ass_ovn
INTO l_ass_obj;
CLOSE csr_ass_ovn;
-- Now Update PER_ALL_PEOPLE_F and PER_ASSIGNMENTS with default Cost Code '9999'
IF insert_flag = 'I'
THEN
BEGIN
DBMS_OUTPUT.PUT_LINE ( ' Updating Employee..:' || v_emp.employee_number );
-- Importing Emp Job, Default Cost Code and Supervisor details --
Hr_Assignment_Api.update_emp_asg
(p_validate => l_validate,
p_effective_date => SYSDATE, -- l_date,
p_datetrack_update_mode => l_datetrack_update_mode,
p_assignment_id => v_emp.assignment_id,
--- ** REQUIRED FIELD **
p_object_version_number => l_ass_obj,
p_supervisor_id => v_emp.supervisor_id,
p_default_code_comb_id => l_default_code_comb_id,
p_concatenated_segments => l_concatenated_segments,
p_soft_coding_keyflex_id => l_soft_coding_keyflex_id,
p_comment_id => l_comment_id,
p_effective_start_date => l_date, --IN/OUT
p_effective_end_date => l_effective_end_date,
p_no_managers_warning => l_no_managers_warning,
p_other_manager_warning => l_other_manager_warning
Hr_Assignment_Api.update_emp_asg_criteria
(p_validate => l_validate,
p_effective_date => SYSDATE, -- l_date,
p_datetrack_update_mode => l_datetrack_update_mode,
p_assignment_id => v_emp.assignment_id,
--- ** REQUIRED FIELD **
p_object_version_number => l_ass_obj,
p_organization_id => l_organization_id,
-- p_location_id => std_location_id,
-- p_job_id => l_job_id,
-- p_position_id => std_position_id,
p_special_ceiling_step_id => l_special_ceiling_step_id,
p_effective_start_date => l_date,
p_effective_end_date => l_effective_end_date,
p_people_group_id => l_people_group_id,
p_group_name => l_group_name,
p_org_now_no_manager_warning => l_org_now_no_manager_warning,
p_other_manager_warning => l_other_manager_warning,
p_spp_delete_warning => l_spp_delete_warning,
p_entries_changed_warning => l_entries_changed_warning,
p_tax_district_changed_warning => l_tax_district_changed_warning
DBMS_OUTPUT.PUT_LINE ( ' Employee Updated..:'
|| v_emp.employee_number
-- End of customer related details
END;
END IF;
END LOOP;
COMMIT;
EXCEPTION
WHEN NO_DATA_FOUND
THEN
ROLLBACK;
-- DBMS_OUTPUT.PUT_LINE ( '"No Data Found" for Employee:' || v_emp.employee_number || SQLERRM );
WHEN OTHERS
THEN
ROLLBACK;
err_num := TO_CHAR (SQLCODE);
err_msg := SUBSTR (SQLERRM, 1, 150);
err_line :=
'Oracle error (seqno='
|| err_seq
|| ') '
|| err_num
|| ' occurred processing record '
|| TO_CHAR (v_rec_cnt + 1)
|| ' : '
|| err_msg;
DBMS_OUTPUT.PUT_LINE (err_line);
INSERT INTO SU_SL_ERRORS
VALUES (err_num, err_msg, SYSTIMESTAMP);
END;
EXIT;Hi
Check if that works for you
/* Formatted on 2009/04/22 14:43 (Formatter Plus v4.8.7) */
SET serveroutput ON SIZE 1000000 FORMAT WRAPPED
SET verify OFF
SET feedback OFF
DECLARE
-- Debugging/error handling
-- Work variables
p_emp_number VARCHAR2 (14);
v_rec_cnt NUMBER := 0;
insert_flag VARCHAR2 (8);
job_exists VARCHAR2 (8);
err_num NUMBER;
err_msg VARCHAR2 (150);
err_line VARCHAR2 (350);
err_seq NUMBER := 0;
l_date DATE := SYSDATE;
l_validate BOOLEAN DEFAULT FALSE;
l_***_obj NUMBER;
l_emp_obj NUMBER;
l_default_code_comb_id NUMBER := 217269;
l_datetrack_update_mode VARCHAR2 (30) := 'CORRECTION';
l_organization_id NUMBER := 0;
l_concatenated_segments VARCHAR2 (240);
l_soft_coding_keyflex_id NUMBER;
l_comment_id NUMBER;
l_effective_end_date DATE
:= TO_DATE ('17-FEB-2059', 'DD-MON-YYYY');
l_no_managers_warning BOOLEAN;
l_special_ceiling_step_id NUMBER;
l_people_group_id NUMBER;
l_group_name VARCHAR2 (30);
l_entries_changed_warning VARCHAR2 (30);
l_spp_delete_warning BOOLEAN;
l_org_now_no_manager_warning BOOLEAN;
l_tax_district_changed_warning BOOLEAN;
l_other_manager_warning BOOLEAN;
l_business_group_id NUMBER := 0;
l_person_id NUMBER;
l_assignment_number VARCHAR2 (35);
l_style VARCHAR2 (4) := 'GB';
ip_p_address_id NUMBER;
l_effective_date DATE := SYSDATE;
l_date_from DATE := SYSDATE;
l_date_to DATE := NULL;
-- CURSOR 1 - get all Existing Employees (well, for testing purps..
just Peter Barlow for now..)
CURSOR c_get_employee_details
IS
SELECT DISTINCT per.person_id, per.employee_number, per.full_name,
paas.assignment_id, paas.supervisor_id,
paas.default_code_comb_id
FROM per_all_people_f per, per_all_assignments_f paas
WHERE per.employee_number = p_emp_number
AND paas.person_id(+) = per.person_id
AND per.person_id = '30188';
-- CURSOR 2 - get all Existing Employees (well, for testing purps.. just Peter Barlow for now..)
CURSOR c_check_employee (p_emp_number VARCHAR2)
IS
SELECT DISTINCT per.person_id, per.employee_number, per.full_name,
paas.assignment_id, paas.supervisor_id,
paas.default_code_comb_id
FROM per_all_people_f per, per_all_assignments_f paas
WHERE per.employee_number = p_emp_number
AND paas.person_id(+) = per.person_id
AND per.person_id = '30188';
emp_rec c_check_employee%ROWTYPE;
-- Cursor 4 retrieves latest Object Version Number from per_assignments_f table..
CURSOR csr_***_ovn (cp_person_id IN per_all_people_f.person_id%TYPE)
IS
SELECT MAX (paas.object_version_number)
FROM per_assignments_f paas, per_all_people_f per
WHERE paas.person_id = per.person_id
AND per.employee_number = paas.assignment_number
AND per.person_id = cp_person_id;
BEGIN
-- UPDATE of EXISTING Employees Details from work table..
FOR v_emp IN c_get_employee_details
LOOP
-- determine whether customer already exists
OPEN c_check_employee (v_emp.employee_number);
LOOP
FETCH c_check_employee
INTO emp_rec;
IF c_check_employee%FOUND
THEN
insert_flag := 'I';
DBMS_OUTPUT.PUT_LINE ('Employee No: ' || v_emp.employee_number);
ELSE
DBMS_OUTPUT.PUT_LINE ( 'Employee No: '
|| v_emp.employee_number
|| ' has not been found! '
insert_flag := 'X';
END IF;
END LOOP;
CLOSE c_check_employee;
-- Obtain the most recent Object Version Number..
OPEN csr_***_ovn (v_emp.person_id);
LOOP
FETCH csr_***_ovn
INTO l_***_obj;
END LOOP;
CLOSE csr_***_ovn;
-- Now Update PER_ALL_PEOPLE_F and PER_ASSIGNMENTS with default Cost Code '9999'
IF insert_flag = 'I'
THEN
BEGIN
DBMS_OUTPUT.PUT_LINE ( ' Updating Employee..:' || v_emp.employee_number );
-- Importing Emp Job, Default Cost Code and Supervisor details --
Hr_Assignment_Api.update_emp_asg
(p_validate => l_validate,
p_effective_date => SYSDATE, -- l_date,
p_datetrack_update_mode => l_datetrack_update_mode,
p_assignment_id => v_emp.assignment_id,
--- ** REQUIRED FIELD **
p_object_version_number => l_***_obj,
p_supervisor_id => v_emp.supervisor_id,
p_default_code_comb_id => l_default_code_comb_id,
p_concatenated_segments => l_concatenated_segments,
p_soft_coding_keyflex_id => l_soft_coding_keyflex_id,
p_comment_id => l_comment_id,
p_effective_start_date => l_date, --IN/OUT
p_effective_end_date => l_effective_end_date,
p_no_managers_warning => l_no_managers_warning,
p_other_manager_warning => l_other_manager_warning
Hr_Assignment_Api.update_emp_asg_criteria
(p_validate => l_validate,
p_effective_date => SYSDATE, -- l_date,
p_datetrack_update_mode => l_datetrack_update_mode,
p_assignment_id => v_emp.assignment_id,
--- ** REQUIRED FIELD **
p_object_version_number => l_***_obj,
p_organization_id => l_organization_id,
-- p_location_id => std_location_id,
-- p_job_id => l_job_id,
-- p_position_id => std_position_id,
p_special_ceiling_step_id => l_special_ceiling_step_id,
p_effective_start_date => l_date,
p_effective_end_date => l_effective_end_date,
p_people_group_id => l_people_group_id,
p_group_name => l_group_name,
p_org_now_no_manager_warning => l_org_now_no_manager_warning,
p_other_manager_warning => l_other_manager_warning,
p_spp_delete_warning => l_spp_delete_warning,
p_entries_changed_warning => l_entries_changed_warning,
p_tax_district_changed_warning => l_tax_district_changed_warning
DBMS_OUTPUT.PUT_LINE ( ' Employee Updated..:'
|| v_emp.employee_number
-- End of customer related details
END;
END IF;
END LOOP;
COMMIT;
END;
EXIT;Thanks -
Hi everyone,
I need to add rounding to this script. I need two versions, one for 1 decimal place and one for 0 decimal places. Can anyone help out?
#target illustrator
addMeasurements();
function addMeasurements() {
var i, doc, imp, met, txtItems, txt, nub;
doc = app.activeDocument;
imp = doc.layers.getByName( 'Text' );
met = doc.layers.add(); met.name = 'New';
txtItems = imp.textFrames;
for ( i = 0; i < txtItems.length; i++ ) {
txtItems[i].duplicate( met, ElementPlacement.PLACEATEND )
txtItems = met.textFrames;
for ( i = 0; i < txtItems.length; i++ ) {
var nub = parseInt( txt = txtItems[i].contents ); // For Numbers only!!!!
txtItems[i].contents = String( txt * 1.1 )
Thanks in advance.The example is just a basic function… Just place it after the main function body in your script… Call it where you need it… here is an example… I changed your parseInt() to parseFloat() to deal with your decmial values… While this should wolk it still may NOT be what you want… i.e. it does nothing about keeping the alpha characters in your text frames the new numbers replace all content…
#target illustrator
addMeasurements();
function addMeasurements() {
var i, doc, imp, met, txtItems, txt, nub;
doc = app.activeDocument;
imp = doc.layers.getByName( 'Numbers' );
met = doc.layers.add(); met.name = 'New';
txtItems = imp.textFrames;
for ( i = 0; i < txtItems.length; i++ ) {
txtItems[i].duplicate( met, ElementPlacement.PLACEATEND )
txtItems = met.textFrames;
for ( i = 0; i < txtItems.length; i++ ) {
var nub = parseFloat( txtItems[i].contents ); // now parseFloat()
nub = nub * 1.123456; // just to check the function rounds…
var rnub = roundToDP( nub, 2 );
txtItems[i].contents = String( rnub ); // replaces all content…?
function roundToDP( n, dP ) {
return Math.round( n * Math.pow( 10, dP ) ) / Math.pow( 10, dP ); -
For multiple selection this script edit help
2 or 3 selection text frame this script run?
selection = app.activeDocument.selection;
for (var j = 0; j<selection.length; ++j);
var doc = app.properties.activeDocument,
myOnjectStyle = doc.objectStyles.itemByName = "myObj1",
myObjects, l;
app.findTextPreferences = app.changeTextPreferences = null;
app.findTextPreferences.findWhat = "^a";
myObjects = (app.selection && app.selection[j]).findText () || doc.findText ();
l = myObjects.length;
while(l--) myObjects[l].pageItems[0].appliedObjectStyle = myOnjectStyle;
n = app.selection[j].textFrames.length;
while (n >= 0)
try {
var islem = app.selection[j].textFrames[n];
islem.appliedObjectStyle = "myObj2";
} catch(_) {}
n--;sorry....i did't mention my error......this is my error...
com.sap.tc.webdynpro.progmodel.context.ContextConfigurationException: DataNodeInfo(Listcustcntrlr.Zread_Input.Output.Es_Mara): structure field __Bev1__Luldegrp not found
with regards,
Gobi
Maybe you are looking for
-
Building iDVD project - white flashes at the beginning of each scene during playback?
I am building a DVD project with multiple movies. I used the Bronze Wedding in the "old themes" menu, which was less problematic than the 7.0 themes. When I click on the segment to play, there is a moment (probably just 1 frame) of white that flash
-
Even more issues after installing 3.1 update. What to do.
HI there, It would seem that since I have installed 3.1 my iPhone 3Gs 32GB white is acting very strange. Heres my story... I have noticed the following behavior since the install. Sound randomly not working. Home button randomly not working. Have don
-
Output word document generation from the properties.
Hi Everybody, I need to generate a word document from the Substance property values stored. How to generate a word document in a specified format.. Thanks, Rajesh.
-
Photoshop Elements 11 filter plug-ins
Hi, I've seen in PSE documentation that it supports filter plug-ins (see http://helpx.adobe.com/pdf/photoshop-elements_reference.pdf page 57) but I can't find the documentation related to plug-in development anywhere. It's not part of Photoshop SDK,
-
hi all I have a problem with batch determination. When I process my out bound delivery delievery document (VL01n) the batch number for the shipment is not getting determined. When I press F4 for the possible values it says, "invalid batch determined"