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...
-carrie
Are 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.
Similar Messages
-
When I run this VI "Waveform Time to Date Time String" in LabView 7.0 it will not pass decimals of seconds. From decimals of inputline. If i disconnect the input to the subVI "Get Date/Time string vi" it will work propperly, it also doses if I reconnect it. I use LabViev 7.0.
So the problem i solved, but i dosent understund why it works in this way. Does it indicate other problems which will make my researchprogram unrelaible ?
Attachments:
Waveform_Time_to_Date_Time_String.vi 18 KBHello.
I checked your vi and it fails as you state.
It runs fine if: 1 Convert number to timestamp OR
2 Wire a constant to want seconds?
In labview 7.1, no problems.
I think is a job for NI engeniers.
Hope it helps
Alipio
"Qod natura non dat, Salmantica non praestat" -
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 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 -
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; -
Script for parsing xml data and inserting in DB
Thank you for reading.
I have the following example XML in an XML file. I need to write a script that can insert this data into an Oracle table. The table does not have primary keys. The data just needs to be inserted.
I do not have xsd file in this scenario. Please suggest how to modify Method 1 https://community.oracle.com/thread/1115266?tstart=0 mentioned so that I can call the XML mentioned below and insert into a table
Method 1
Create or replace procedure parse_xml is
l_bfile BFILE;
l_clob CLOB;
l_parser dbms_xmlparser.Parser;
l_doc dbms_xmldom.DOMDocument;
l_nl dbms_xmldom.DOMNodeList;
l_n dbms_xmldom.DOMNode;
l_file dbms_xmldom.DOMNodeList;
l_filen dbms_xmldom.DOMNode;
lv_value VARCHAR2(1000);
l_ch dbms_xmldom.DOMNode;
l_partname varchar2(100);
l_filename varchar2(1000);
l_temp VARCHAR2(1000);
TYPE tab_type IS TABLE OF tab_software_parts%ROWTYPE;
t_tab tab_type := tab_type();
BEGIN
l_bfile := BFileName('DIR1', 'SoftwareParts.xml');
dbms_lob.createtemporary(l_clob, cache=>FALSE);
dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
dbms_lob.loadFromFile(dest_lob => l_clob, src_lob => l_bfile, amount => dbms_lob.getLength(l_bfile));
dbms_lob.close(l_bfile);
dbms_session.set_nls('NLS_DATE_FORMAT','''DD-MON-YYYY''');
l_parser := dbms_xmlparser.newParser;
dbms_xmlparser.parseClob(l_parser, l_clob);
l_doc := dbms_xmlparser.getDocument(l_parser);
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'/PartDetails/Part');
FOR cur_emp IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP
l_n := dbms_xmldom.item(l_nl, cur_emp);
t_tab.extend;
dbms_xslprocessor.valueOf(l_n,'Name/text()',l_partname);
t_tab(t_tab.last).partname := l_partname;
l_file := dbms_xslprocessor.selectNodes(l_n,'Files/FileName');
FOR cur_ch IN 0 .. dbms_xmldom.getLength(l_file) - 1 LOOP
l_ch := dbms_xmldom.item(l_file, cur_ch);
lv_value := dbms_xmldom.getnodevalue(dbms_xmldom.getfirstchild(l_ch));
if t_tab(t_tab.last).partname is null then t_tab(t_tab.last).partname := l_partname; end if;
t_tab(t_tab.last).filename := lv_value;
t_tab.extend;
END LOOP;
END LOOP;
t_tab.delete(t_tab.last);
FOR cur_emp IN t_tab.first .. t_tab.last LOOP
if t_tab(cur_emp).partname is not null and t_tab(cur_emp).filename is not null then
INSERT INTO tab_software_parts
VALUES
(t_tab(cur_emp).partname, t_tab(cur_emp).filename);
end if;
END LOOP;
COMMIT;
dbms_xmldom.freeDocument(l_doc);
EXCEPTION
WHEN OTHERS THEN
dbms_lob.freetemporary(l_clob);
dbms_xmlparser.freeParser(l_parser);
dbms_xmldom.freeDocument(l_doc);
END;
<TWObject className="TWObject">
<array size="240">
<item>
<variable type="QuestionDetail">
<questionId type="String"><![CDATA[30]]></questionId>
<questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
<country type="String"><![CDATA[GB]]></country>
<questionText type="String"><![CDATA[Please indicate]]></questionText>
<optionType type="String"><![CDATA[RadioButton]]></optionType>
<answerOptions type="String[]">
<item><![CDATA[Yes]]></item>
<item><![CDATA[No]]></item>
</answerOptions>
<ruleId type="String"><![CDATA[CRP_GB001]]></ruleId>
<parentQuestionId type="String"></parentQuestionId>
<parentQuestionResp type="String"></parentQuestionResp>
</variable>
</item>
<item>
<variable type="QuestionDetail">
<questionId type="String"><![CDATA[40]]></questionId>
<questionType type="questionType"><![CDATA[COUNTRY]]></questionType>
<country type="String"><![CDATA[DE]]></country>
<questionText type="String"><![CDATA[Please indicate]]></questionText>
<optionType type="String"><![CDATA[RadioButton]]></optionType>
<answerOptions type="String[]">
<item><![CDATA[Yes]]></item>
<item><![CDATA[No]]></item>
</answerOptions>
<ruleId type="String"><![CDATA[CRP_Q0001]]></ruleId>
<parentQuestionId type="String"></parentQuestionId>
<parentQuestionResp type="String"></parentQuestionResp>
</variable>
</item>
</array>
</TWObject>Reposted as
Script to parse XML data into Oracle DB -
We just bought apple tv for our home in Canada, we also want to use it at our Cabin in Montana. We have internet and can get netflix etc on the Macbook, but don't seem to be able to hook up the Apple TV, it just keeps asking for the Time and Date over and over. Anyone know what we are doing wrong?
Hi There,
Find this here:
https://discussions.apple.com/message/20125520#20125520
Problem lies with IOS 6.0
Restore back to IOS 5.1.1 and set the Location to US you will be ok. -
[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) -
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. -
OIM 11g Modify User Profile for Updating End Date
Hi Gurus!
We have an OIM implementation where users may request the creation of other users by means of a Create User request template. In this template we set the End Date to be 3 months after the request date.
In order for the requester to extend the period of a user's OIM user account (along with its provisioned resources) we customized a Modify User Profile by displaying the End Date field and automatically populate it again to 3 months after the request date. Also we developed a custom event handler to enable the user when it is disabled and the End Date is updated to a future date.
This Modify User Profile is working great when the user is still enabled (the End Date is still in the future), however, when the End Date has passed (and the user is Disabled) the requester is not able to see the user when selecting the Modify User Profile request template.
Is there a way to allow requesters to also see disabled users in the Modify User Profile request template?
Thank you in advance.
Regards,Hi Kevin,
thanks for your reply!
But, in this case, when the user is already disabled due to his End Date, how can a requester, through the Self Service TAB, enable it?
The Enable User request template does not work since when trying to enable the user, OIM sees the End Date is already passed and the DataSet validation throws an exception.
The only way I saw was providing a Modify User Profile Request template to change the End Date and developing a custom event handler to enable the user upon the extension of the End Date...
How can, in this situation, a requester enable the user and extend its End Date?
Thank you!
Regards, -
SPC charts for time-based data?
I'll try to be succinct in explaining what I'm trying to achieve.
We run batch processes, and at various points in the process we take samples and test them. The sample results should be increasing exponentially over the course of the batch. I have data from a lot of batches in x/y format - x is the duration of the batch and y is the sample result. It makes a very noisy but clearly exponentially increasing data set.
What I want is to calculate some control limits that will obviously have to be increasing over time as well. I want to be able to say that, for a current batch, a sample at X time does or does not fall within the expected historical range.
Is this even possible with xMII, either in the logic editor or the iSPC charts?
I'd like to make the same sort of chart for other time-based samples that have more complex trends over the duration of a batch, not simply exponential or linear.Hi, Carrie.
Your application doesn't really sound like what I would call an "SPC" chart, but rather, more of a so-called "golden batch" chart. This type of visualization is used when a production activity should have an expected set of value(s) and/or a shape to a curve. You would then "overlay" actual values onto this curve to track actual vs. expected and perhaps to highlight deviations.
This can best be done by combining a multiple queries using BLS (one or more queries for the "limits" and expected values, one query for the actual values), and combining/merging them so that the charting engine (either a line/marker chart or an XY plot) sees them as coming from a single source.
With some creativity, you can even have the "outlier" points displayed in another color. The xMII application team can help you with setting this up - Jeremy may still have a chart template/transaction I put together a while back called "LimitChart", which could be used for your application.
Rick -
Apply overrides (Can anyone «cook» this script for me?)
Hi, everybody!
Here I am again asking for something: I need a script that clears all overrides that exist in a certain style paragraph that was applied thousands of times in a very long Indesign document.
Thank you in advance
MariaIf it's just one paragraph style: use Search and Replace. Put the same paragraph style in both Search and Replace formatting fields, and make sure there is no text at all in the text edit fields. It seems you want to replace the style with the exact same style ... but in this particular case, every manual override gets fried (to continue your cooking analogy ).
-
Master data records for time dependant data
Hi
In R/3. say master data has 1500 records. In BW, while loading this, i get the same number of records in monitor.
But when i check the maintain master data for this info object, I find each row being duplicated. The difference being the valid to and valid from date. The info object is time dependant.
So my question is: this adjustment done...is it ok continuing forward or do we change something now so that i dont see duplicate rows?
Thanks in advance
ARhi,
everything is ok here (I assume you have timeframes for e.g.: 01.01.1000 - 27.12.2005 and 28.12.2005 - 31.12.9999).
If you are working on developement system now - change something time-dependent in your master data tommorow (in your source system) and extract delta. Two new periods will be created and you will have 3 records, e.g.: 01.01.1000 - 27.12.2005 , 28.12.2005 - 28.12.2005 and 29.12.2005 - 31.12.9999.
Regards,
Andrzej -
Can anyone spot the error in this script for iTunes?
This AppleScript is designed to copy the Name and Artist of an iTunes track, then populate the Album Artist field with both, separated with an oblique. But when I run the script in iTunes, it only pastes the Artist name in to the Album Artist field and not the whole string.
tell application "iTunes"
if selection is not {} then -- if tracks are selected...
set sel to selection
set numTracks to (length of sel)
set s to "s"
if numTracks is 1 then set s to ""
display dialog "Adds the name of the track and the name of the artist to the Album Artist field." & return & return & (numTracks & " track" & s & " selected.") buttons {"Cancel", "Continue"} default button 2 with title "Create Album Artist" giving up after 30
if gave up of result is true then return
repeat with t from 1 to numTracks
tell contents of item t of sel
set {album artist} to ({get artist} & " / " & {get name})
end tell
end repeat
else
display dialog "No tracks have been selected." buttons {"Cancel"} default button 1 with icon 0 giving up after 30
end if -- no selection
end tellHello
Try -
tell item t of sel
set album artist to (get artist) & " / " & (get name)
end tell
instead of -
tell contents of item t of sel
set {album artist} to ({get artist} & " / " & {get name})
end tell
In your original code, the left and right value of assignment are both list, i.e. -
left value = {album artist}
right value = {get artist, "/", get name}
Consequently 'album artist' is assigned to the 1st item of the list at right, which is the result of 'get artist'.
In order to avoid this, don't use list assingment, which is not necessary at all here.
Also, I think you may just tell item t of sel, not contents of item t of sel.
Hope this may help,
H -
as soon as i click on a link and select open in anew tab i face the window asking me to stop or debug a script...for almost every website
Does it mention a chrome:// URL in the error message that might indicate a problem with an extension?
Firefox uses the "chrome://" protocol to access its own internal files and also access files from extensions (no connection with Google Chrome).
*https://developer.mozilla.org/en/Chrome
Note that your System Details List shows multiple Flash plugins.
*Shockwave Flash 12.0 r0
*Shockwave Flash 11.7 r700
You can find the installation path of all plugins on the <b>about:plugins</b> page.
*http://kb.mozillazine.org/Issues_related_to_plugins#Identifying_installed_plugins
You can check the Flash player installation folder for multiple Flash player plugins and remove older version(s) of the plugin (NPSWF32) and possibly (re)install the latest Flash player.
*(32 bit Windows) C:\Windows\System32\Macromed\Flash\
*(64 bit Windows) C:\Windows\SysWOW64\Macromed\Flash\
Maybe you are looking for
-
why my apple id not support in icloud
-
What is the newest OS I can load in a MacBook A1134
Currently it's OS 10.4.11
-
Dear experts Our client implemented sap in 2006 ECC 6 version and 2011 they want to implement new profit center instead of old profit center .I have discussed with client what they are saying they have implemented document
-
How do I download Creative Suite 6 Design & Web Premium after restoring my computer
I had to refresh my computer and it uninstalled my Adobe products. How do I get them back. I don't have the option through cloud. It only gives the option to upgreade. HELP!!
-
I need to know how i can find difference between date like Joining date: 01-jan-2009 Today 10-jan-2010 result will be "1 year 10 days" I need it in Oracle forms 6i. plz help me...