Scripting Assistance
I am new to Java and looking for assistance with some basic scripting. The following 2 .java files are used to complete a mortgage calculation, and for some reason I am always ending up dividing by zero in my mortgage calculation equation (CalcEvent.java). This is called by MortgageGUI1.java. Any assistance anyone can provide would be very much appreciated.....
MortgageGUI1.java
* Program Name : Mortgage GUI 1
* Course : POS 407 - Week Two Assignment
* Original Version : 9 October 2004
* This Revision : 9 October 2004
* Programmer : Clifton Smith
* Purpose : This program will display a GUI which allows the
* user to input the loan amount, term of the loan,
* and the interest rate for a mortgage, upon which
* a monthly payment will be calculated and displayed.
* Version 1.0
/* Import the necessary Java APIs */
import java.awt.*;
import javax.swing.*;
/* Define the class */
public class MortgageGUI1 extends JFrame {
CalcEvent mort = new CalcEvent(this);
/* Set up Row 1 */
JPanel row1 = new JPanel();
JLabel principalLabel = new JLabel("Amount of the loan in whole dollars ", JLabel.RIGHT);
JTextField principal = new JTextField(20);
/* Set up Row 2 */
JPanel row2 = new JPanel();
JLabel termLabel = new JLabel("Length of the loan ", JLabel.RIGHT);
JTextField term = new JTextField(20);
/* Set up Row 3 */
JPanel row3 = new JPanel();
ButtonGroup option = new ButtonGroup();
JCheckBox months = new JCheckBox("Months", false);
JCheckBox years = new JCheckBox("Years", true);
/* Set up Row 4 */
JPanel row4 = new JPanel();
JLabel interestLabel = new JLabel("Interest Rate ", JLabel.RIGHT);
JTextField interest = new JTextField(20);
/* Set up Row 5 */
JPanel row5 = new JPanel();
JButton calculate = new JButton("Calculate");
JButton reset = new JButton("Reset");
/* Set up Row 6 */
JPanel row6 = new JPanel();
JLabel paymentLabel = new JLabel("Amount of Monthly Payment ", JLabel.RIGHT);
JTextField payment = new JTextField(20);
/* Subclass to draw the Java GUI */
public MortgageGUI1() {
super("JAVA Mortgage Calculator");
setSize(500, 300);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridLayout assemble = new GridLayout(6, 1, 10, 10);
Container pane = getContentPane();
pane.setLayout(assemble);
/* Add Listeners */
months.addItemListener(mort);
years.addItemListener(mort);
calculate.addActionListener(mort);
reset.addActionListener(mort);
/* Drawing Row 1 */
GridLayout assemble1 = new GridLayout(1, 2, 10, 10);
row1.setLayout(assemble1);
//row1.setLayout(assemble1);
row1.add(principalLabel);
row1.add(principal);
pane.add(row1);
/* Drawing Row 2 */
GridLayout assemble2 = new GridLayout(1, 2, 10, 10);
row2.setLayout(assemble2);
//row2.setLayout(assemble2);
row2.add(termLabel);
row2.add(term);
pane.add(row2);
/* Drawing Row 3 */
FlowLayout assemble3 = new FlowLayout(FlowLayout.CENTER, 10, 10);
option.add(months);
option.add(years);
row3.setLayout(assemble3);
row3.add(months);
row3.add(years);
pane.add(row3);
/* Drawing Row 4 */
GridLayout assemble4 = new GridLayout(1, 2, 10, 10);
row4.setLayout(assemble4);
//row4.setLayout(assemble4);
row4.add(interestLabel);
row4.add(interest);
pane.add(row4);
/* Drawing Row 5 */
FlowLayout assemble5 = new FlowLayout(FlowLayout.CENTER, 10, 10);
option.add(calculate);
option.add(reset);
row5.setLayout(assemble5);
row5.add(calculate);
row5.add(reset);
pane.add(row5);
/* Drawing Row 6 */
GridLayout assemble6 = new GridLayout(1, 2, 10, 10);
row6.setLayout(assemble6);
//row6.setLayout(assemble6);
row6.add(paymentLabel);
row6.add(payment);
pane.add(row6);
/* Displaying the Pane */
setContentPane(pane);
setVisible(true);
} /* End of MortgageGUI1 Subclass */
/* Define the main class */
public static void main(String[] arguments) {
MortgageGUI1 frame = new MortgageGUI1();
} /* End of main class */
} /* End of MortgageGUI1 JFrame Subclass */
CalcEvent.java
* Program Name : CalcEvent
* Course : POS 407 - Week Two Assignment
* Original Version : 9 October 2004
* This Revision : 9 October 2004
* Programmer : Clifton Smith
* Purpose : This program will calculate the monthly payment
* and interpret start and reset actions from the
* MortgageGUI1 program.
* Version 1.0
/* Import the necessary Java APIs */
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.io.*;
import java.text.DecimalFormat;
/* Define the class */
public class CalcEvent implements ItemListener, ActionListener, Runnable {
/* Start the GUI */
MortgageGUI1 gui;
Thread calculating;
/* Define MortgageGUI1 as an attribute of CalcEvent */
public CalcEvent(MortgageGUI1 in) {
gui = in;
/* Define the actions of the program */
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
if (command == "Calculate")
startCalculating();
if (command == "Reset")
clearFields();
void startCalculating() {
calculating = new Thread(this);
calculating.start();
gui.calculate.setEnabled(false);
gui.reset.setEnabled(false);
gui.months.setEnabled(false);
gui.years.setEnabled(false);
void clearFields() {
gui.principal.setText(null);
gui.term.setText(null);
gui.interest.setText(null);
gui.payment.setText(null);
gui.months.setEnabled(true);
gui.years.setEnabled(true);
/* Define method to handle months vs. years selection */
int time;
int p;
int i;
public void itemStateChanged(ItemEvent event) {
Object choice = event.getItem();
if (choice == gui.years) {
time = Integer.parseInt( gui.term.getText() );
time = (time * 12);
else {
time = Integer.parseInt( gui.term.getText() );
String tempString;
public void run() {
Thread thisThread = Thread.currentThread();
while (calculating == thisThread) {
tempString = gui.principal.getText().trim ();
p = (new Integer(tempString)).intValue();
tempString = gui.interest.getText().trim ();
i = (new Integer(tempString)).intValue();
int rate = (1 + (i / 1200));
//int rate = (1 + ((Integer.parseInt( gui.interest.getText() ) / 1200)));
double mortgage = ((p * i * (Math.pow(rate,time))) / (1200 * (Math.pow(rate,time) - 1)));
//double mortgage = (((Integer.parseInt( gui.principal.getText() )) * (Integer.parseInt( gui.interest.getText() )) * (Math.pow(rate,time)))/(1200 * (Math.pow(rate,time) - 1)));
mortgage = (Math.rint(mortgage * 100)) / 100;
//gui.payment.setText("$" + (tempString.valueOf(mortgage)));
float monthlyPayment = (float)mortgage;
gui.payment.setText("$" + monthlyPayment);
/* Reset GUI field values */
gui.calculate.setEnabled(true);
gui.reset.setEnabled(true);
calculating = null;
}
I am always ending up dividing by zero...That's because you're working with int values, not floating point numbers.
System.out.println(1 / 2); // 0
System.out.println(1.0 / 2); // 0.5
SOME THINGS YOU SHOULD KNOW ABOUT FLOATING-POINT ARITHMETIC
What Every Computer Scientist Should Know About Floating-Point Arithmetic
Similar Messages
-
Java Script Assistant in xMII 12.0
Hi All,
Kindly help me to find out the "Java Script Assistance in xMII 12.0" version.
Thanks
Rajesh Sivaprakasam.
Edited by: Rajesh Sivaprakasam on Nov 27, 2008 12:05 PMHelo Rajesh,
the Productivity Wizards are available under SDN->Downloads->for Manufacturing->xMII 12.0 Sample Projects and Tools.
Link:
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/e0171f05-98c6-2a10-f5a0-8f2ec79d10a4
Regards
Pedro -
Script Assist in Actions Panel
In the Flash MX Professional I do not have the option of
activating the Script Assist function. I'm not well-versed in
actionscript and need the assistance to make my projects
functional. I work on a Mac using OS X Panther. Has anyone else run
into this problem and, if so, how did you resolve it? TxHEY! SCREW OFF! i was trying to help you out you ******* -
and providing a little levity from the title you've posted - i
thought it was a great title and a fun way to ask - apparently you
didn't see the 'just kidding - wink" - i thought that was exactly
the answer you were looking for but didn't know what to call it -
so SCREW OFF YOU PR!CK!
you don't know what you talking about - if all you saw was
comics dipsh!t, you didn't look around or notice anything else -
not to mention that i script for a living and none of those were
'web comics' - I've got more abilities than you will ever have!
to call someone a '****' in your second post! holy crap -
what an *** - don't come around here anymore, you don't have any
business even thinking about trying to code ... LMFAO! -
UCCX 8.5.1 Scripting Assistance - Set Priority
Hello,
I am trying to configure the priority in my script similar to how they did this in the below discussion.
https://supportforums.cisco.com/discussion/11892936/uccx-851-basic-scripting-assistance-set-priority
When I put the "set priority" in the script it errors out and callers hear the message that the system is experiencing problems. The script runs fine without the "set priority". Any assistance would be greatly appreciated.Chris,
I attempted to validate the script and did get an error with the "Set Enterprise Call Info" step. What's odd is that without the priority step the script still does not validate, but actually works fine. As soon as I add the priority step to it though it breaks.
I removed the "Set Enterprise Call Info" step and the priority works as expected now. Thank you for your assistance.
Jared -
Hello please forgive me as I am new to this but really need assistance. I have a form created in html on a site and have tried numerous tutorials on creating a php script which would be linked to this html form, but each one I try either doesn't work or it seems as if it goes through but then I never recieve the mail in my mailbox. I used my yahoo account as well as another account and didn't get anything , can anyone please assist as to what I should do here is what I have so far.
Thank you in advance for any assistance provided.
HTML:
<form name="contactform" method="post" action="mailer.php">
Name <input type="text" name="name"/><br/><br/>
Email <input type="text" name="email"/><br/><br/>
Address <input type="text" name="address"/><br/><br/>
City <input type="text" name="city"/><br/><br/>
When to Contact <select name="dropdown">
<option value="Morning">Morning</option>
<option value="Afternoon">Afternooon</option>
<option value="Evening">Evening</option>
</select><br/><br/>
Purpose of Contact <br/><textarea name="commment" rows="6" cols="40">
</textarea><br/> <br/><input type="submit" value="Submit Form Now" name="submit"/>
</form>
Here is the script that I am using :
<?php
if(isset($_POST['submit'])) {
$to = "[email protected]";
$subject = "Inquiry Form";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$address_field = $_POST['address'];
$city_field = $_POST['city'];
$comment= $_POST['comment'];
$dropdown = $_POST['dropdown'];
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value\n";
$body = "From: $name_field\n E-Mail: $email_field\n $check_msg Option: $option\n Drop-Down: $dropdown\n Message:\n $message\n";
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
} else {
echo "Form not Submitted!";
?>Hello thank you for responding... yes I believe it is , I have used a drag and drop flash component with a php script for another project I had worked on not too long ago and it worked fine. Im pretty sure it is running.
Does the code and script that I provided look correct to you? -
RA&R Rule Script assistance required
Hi Forum guru's,
We are customising RA&R, Ver 5.3, SP 10 and require some assistance with the SQL script. We are attempting to disable +-4600 rules at ACTION LEVEL and the tables we are referering to in the script are AC_RULE & AC_HEADER.
The script runs successfully and disables the rules, however the moment we re-run the rule generation background job, all the disabled rules are then re-enabled.
I am sure we are missing a table. Can anybody provide some assistance, or has anybody experienced something similar?
Rgds,
Prevo.Hi Alpesh,
Thanks for the advice, however this was done previously by a colleague on AC version 5.2.
I do agree that it is "safer" to disable the tcode/aut object from the function itself, however this would be quite
time consuming for over 4500 rules.
Would you perhaps know the tables that we could use in our Script?
Rgds,
Prevo -
I am looking for FLASH Action Script Assistance.
What's the best source to find a person to assist with Compiler errors related to Flash scripts?
Compiler errors: I have attempted to correct Source according to the suggestions by the compiler errors to no avail.
The SOURCE CODE appears below the COMPILER ERRORS.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 32, Column 17
1084: Syntax error: expecting identifier before greaterthan.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 46, Column 10
1084: Syntax error: expecting identifier before greaterthan.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 62, Column 17
1084: Syntax error: expecting identifier before greaterthan.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 77, Column 10
1084: Syntax error: expecting identifier before greaterthan.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 94, Column 17
1084: Syntax error: expecting identifier before greaterthan.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 95, Column 17
1084: Syntax error: expecting identifier before greaterthan.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 95, Column 21
1084: Syntax error: expecting rightparen before leftbrace.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 125, Column 32
1084: Syntax error: expecting rightparen before and.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 127, Column 36
1084: Syntax error: expecting rightparen before and.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 147, Column 28
1084: Syntax error: expecting identifier before greaterthan.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 147, Column 34
1084: Syntax error: expecting rightparen before _root.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 170, Column 17
1084: Syntax error: expecting identifier before greaterthan.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 171, Column 17
1084: Syntax error: expecting identifier before greaterthan.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 171, Column 21
1084: Syntax error: expecting rightparen before leftbrace.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 186, Column 32
1084: Syntax error: expecting rightparen before and.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 188, Column 36
1084: Syntax error: expecting rightparen before and.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 208, Column 28
1084: Syntax error: expecting identifier before greaterthan.
Symbol 'slidingMenu', Layer 'as', Frame 1, Line 208, Column 34
1084: Syntax error: expecting rightparen before _root.
========================================================================================== ================================
Source for slidingMenu
slidingMenu.RollOverBoxes = function(boxNumber:Number) {
if (_root.link<>boxNumber) {
_root.my_motion_finished = 0;
var cBox:MovieClip = eval('box'+boxNumber);
cBox.title_main.gotoAndPlay("s1");
for (var i = 1; i<=7; i++) {
var cBox:MovieClip = eval('box'+i);
xkoord = cBox.my_x;
if (_root.splash_flag == 1) {
if (boxNumber == 1) {
slidingMenu.move_all(126);
} else {
slidingMenu.move_all(-126);
if (i<>boxNumber) {
if (i<boxNumber) {
_root.myTween = new Tween(cBox, "_x", Strong.easeOut, cBox._x, xkoord-small_height_over, time_for_animation2, false);
cBox.my_x = xkoord-small_height_over;
} else {
_root.myTween = new Tween(cBox, "_x", Strong.easeOut, cBox._x, xkoord+small_height_over, time_for_animation2, false);
cBox.my_x = xkoord+small_height_over;
_root.myTween.onMotionFinished = function() {
_root.my_motion_finished = 1;
slidingMenu.RollOutBoxes = function(boxNumber:Number) {
if (_root.link<>boxNumber) {
_root.my_motion_finished2 = 0;
var cBox:MovieClip = eval('box'+boxNumber);
//cBox.title_main.gotoAndPlay("s2");
cBox.title_main.gotoAndPlay("s2");
for (var i = 1; i<=7; i++) {
var cBox:MovieClip = eval('box'+i);
xkoord = cBox.my_x;
if (_root.splash_flag == 1) {
if (boxNumber == 1) {
slidingMenu.move_all(-126);
} else {
slidingMenu.move_all(-126);
if (i<>boxNumber) {
if (i<boxNumber) {
_root.myTween = new Tween(cBox, "_x", Strong.easeOut, cBox._x, xkoord+small_height_over, time_for_animation2, false);
cBox.my_x = xkoord+small_height_over;
} else {
_root.myTween = new Tween(cBox, "_x", Strong.easeOut, cBox._x, xkoord-small_height_over, time_for_animation2, false);
cBox.my_x = xkoord-small_height_over;
_root.myTween.onMotionFinished = function() {
_root.my_motion_finished2 = 1;
// Functions
slidingMenu.moveBoxes = function(boxNumber:Number) {
if (_root.link<>boxNumber) {
if (boxNumber<>7) {
small_height = 568;
small_height_over = 0;
} else {
small_height = 208;
small_height_over = 360;
if (boxNumber == 7) {
_root.splash_flag = 1;
slidingMenu.move_all(-126);
} else {
_root.splash_flag = 0;
if (boxNumber == 5) {
//slidingMenu.move_all(196-boxNumber*593+780);
slidingMenu.move_all(136-(boxNumber-1)*593);
} else {
if (boxNumber == 1) {
//slidingMenu.move_all(196-boxNumber*593+320);
slidingMenu.move_all(136-(boxNumber-1)*593);
} else {
slidingMenu.move_all(136-(boxNumber-1)*593);
_root.my_motion_finished3 = 0;
k = 1;
//-1239.0
//eval('box'+_root.link).title_main.gotoAndPlay("s2");
for (var i = 1; i<=7; i++) {
var cBox:MovieClip = eval('box'+i);
if (_root.start_status == 0 and i<>boxNumber) {
//cBox.title_main.gotoAndPlay("s3");
} else if (_root.link_prev == 0 and i == boxNumber) {
//cBox.title_main.gotoAndPlay("s6");
if (i == boxNumber) {
_root.link_prev = _root.link;
_root.link = boxNumber;
cBox.pages.gotoAndPlay("s1");
//if (_root.link<>0) {
//cBox.title_main.gotoAndPlay("s2");
var cBox2:MovieClip = eval('box'+_root.link_prev);
cBox2.title_main.gotoAndPlay("s2");
_root.pic_num_prev = _root.pic_num;
_root.pic_num = 1;
_root.pic_num2_prev = _root.pic_num2;
_root.pic_num2 = 1;
_root.pic_num3_prev = _root.pic_num3;
_root.pic_num3 = 1;
_root.pic_num4_prev = _root.pic_num4;
_root.pic_num4 = 1;
if (_root.pic_num_prev<>1 or _root.pic_num2_prev<>1 or _root.pic_num3_prev<>1 or _root.pic_num4_prev<>1) {
cBox2.title_main.area.gall.play();
cBox2.pages.gotoAndPlay(cBox2.pages._totalframes-cBox2.pages._currentframe);
_root.scroller.gotoAndStop(2);
xkoord = cBox.my_x;
if (i<=boxNumber) {
_root.myTween = new Tween(cBox, "_x", Back.easeOut, cBox._x, (k)*(small_height)-200, time_for_animation, false);
cBox.my_x = (k)*(small_height)-200;
} else {
_root.myTween = new Tween(cBox, "_x", Back.easeOut, cBox._x, (k)*(small_height)+big_height-232, time_for_animation, false);
cBox.my_x = (k)*(small_height)+big_height-232;
_root.myTween.onMotionFinished = function() {
_root.my_motion_finished3 = 1;
k++;
_root.start_status = 1;
slidingMenu.appearBoxes = function(boxNumber:Number) {
if (_root.link<>boxNumber) {
if (boxNumber<>7) {
if (boxNumber == 1) {
slidingMenu.move_all(396-boxNumber*93);
} else {
slidingMenu.move_all(336-boxNumber*93);
} else {
slidingMenu.move_all(-426);
_root.my_motion_finished3 = 0;
k = 1;
//-1239.0
//eval('box'+_root.link).title_main.gotoAndPlay("s2");
for (var i = 1; i<=7; i++) {
var cBox:MovieClip = eval('box'+i);
if (_root.start_status == 0 and i<>boxNumber) {
//cBox.title_main.gotoAndPlay("s3");
} else if (_root.link_prev == 0 and i == boxNumber) {
//cBox.title_main.gotoAndPlay("s6");
if (i == boxNumber) {
_root.link_prev = _root.link;
_root.link = boxNumber;
cBox.pages.gotoAndPlay("s1");
//if (_root.link<>0) {
//cBox.title_main.gotoAndPlay("s2");
var cBox2:MovieClip = eval('box'+_root.link_prev);
cBox2.title_main.gotoAndPlay("s2");
_root.pic_num_prev = _root.pic_num;
_root.pic_num = 1;
_root.pic_num2_prev = _root.pic_num2;
_root.pic_num2 = 1;
_root.pic_num3_prev = _root.pic_num3;
_root.pic_num3 = 1;
_root.pic_num4_prev = _root.pic_num4;
_root.pic_num4 = 1;
if (_root.pic_num_prev<>1 or _root.pic_num2_prev<>1 or _root.pic_num3_prev<>1 or _root.pic_num4_prev<>1) {
cBox2.title_main.area.gall.play();
cBox2.pages.gotoAndPlay(cBox2.pages._totalframes-cBox2.pages._currentframe);
_root.scroller.gotoAndStop(2);
xkoord = cBox.my_x;
if (i<=boxNumber) {
_root.myTween = new Tween(cBox, "_x", Strong.easeOut, cBox._x, (k)*(small_height)-200, 5+int(70-k*5), false);
cBox.my_x = (k)*(small_height)-200;
} else {
_root.myTween = new Tween(cBox, "_x", Strong.easeOut, cBox._x, (k)*(small_height)+big_height-232, time_for_animation+int(k*20), false);
cBox.my_x = (k)*(small_height)+big_height-232;
_root.myTween.onMotionFinished = function() {
_root.my_motion_finished3 = 1;
k++;
_root.start_status = 1;
slidingMenu.StopBoxes = function() {
for (var i = 1; i<=7; i++) {
var cBox:MovieClip = eval('box'+i);
//_root.myTween = new Tween(cBox, "_x", Back.easeOut, cBox._x, xkoord-small_height_over, 1, false);
_root.myTween.continueTo(1, 1);
slidingMenu.move_all = function(num) {
var cBox:MovieClip = _root.box1;
_root.myTween_move_all = new Tween(cBox, "_x", Back.easeOut, cBox._x, num, 25, false);
//slidingMenu.moveBoxes(); -
Powershell script assistance - adding another property to existing script
This is not my script but was written by Richard L. Mueller. It works perfectly for us but I would like to know if the account is enabled or disabled when the output is created. Basically it would output the name, lastlogon and then either enabled or disabled.
I've attempted to add a new property by adding another " $Searcher.PropertiesToLoad.Add" and "$Result.Properties.Item ".
It works fine if I add something like "givenName" but I can't find the property name to show if the account is enabled or disabled.
The entire script is shown below:
# PSLastLogon.ps1
# PowerShell script to determine when each user in the domain last
# logged on.
# Copyright (c) 2011 Richard L. Mueller
# Hilltop Lab web site - http://www.rlmueller.net
# Version 1.0 - March 16, 2011
# This program queries every Domain Controller in the domain to find the
# largest (latest) value of the lastLogon attribute for each user. The
# last logon dates for each user are converted into local time. The
# times are adjusted for daylight savings time, as presently configured.
# You have a royalty-free right to use, modify, reproduce, and
# distribute this script file in any way you find useful, provided that
# you agree that the copyright owner above has no warranty, obligations,
# or liability for such use.
Trap {"Error: $_"; Break;}
$D = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
$Domain = [ADSI]"LDAP://$D"
$Searcher = New-Object System.DirectoryServices.DirectorySearcher
$Searcher.PageSize = 200
$Searcher.SearchScope = "subtree"
$Searcher.Filter = "(&(objectCategory=person)(objectClass=user))"
$Searcher.PropertiesToLoad.Add("distinguishedName") > $Null
$Searcher.PropertiesToLoad.Add("lastLogon") > $Null
# Create hash table of users and their last logon dates.
$arrUsers = @{}
# Enumerate all Domain Controllers.
ForEach ($DC In $D.DomainControllers)
$Server = $DC.Name
$Searcher.SearchRoot = "LDAP://$Server/" + $Domain.distinguishedName
$Results = $Searcher.FindAll()
ForEach ($Result In $Results)
$DN = $Result.Properties.Item("distinguishedName")
$LL = $Result.Properties.Item("lastLogon")
If ($LL.Count -eq 0)
$Last = [DateTime]0
Else
$Last = [DateTime]$LL.Item(0)
If ($Last -eq 0)
$LastLogon = $Last.AddYears(1600)
Else
$LastLogon = $Last.AddYears(1600).ToLocalTime()
If ($arrUsers.ContainsKey("$DN"))
If ($LastLogon -gt $arrUsers["$DN"])
$arrUsers["$DN"] = $LastLogon
Else
$arrUsers.Add("$DN", $LastLogon)
# Output latest last logon date for each user.
$Users = $arrUsers.Keys
ForEach ($DN In $Users)
$Date = $arrUsers["$DN"]
"$DN;$Date"It is part of the userAccountControl attribute. Retrieve that attribute for each user and test if the ADS_UF_ACCOUNTDISABLE bit (2) is set.
-- Bill Stewart [Bill_Stewart] -
I'm working on a form. What I need it to do is this:
The end user will check a box to add comments. The comments field is NOT visable until the check box is checked. Once the checkbox is checked then a text box will appear directly underneath it.
Thank you in advance!
SRenaedo you mean where are the textbox and checkbox located on my form or in the hierarchy?
I have the checkbox and textbox in their own subform.
if
(Checkbox1.rawValue==1) Textfield1.presence="visible"
elseTextfield1.presence
="hidden"
Sorry that I'm being a pain! I'm not well-versed in scripting if that isn't obvious! ;-) -
Script assistance to export\import LegacyExchangeDN
Hi Everyone,
I'm currently in the process of migrating our hosted exchange customers from one site to another.
I'm looking for a way to create CSV file that will contain the fields: Alias, EmailAddress and LegacyExchangeDN, and a way to use CSV file in order to create X500 addresses for each account based on the details.
For organization with 5-20 users, manual work is acceptable, but manually setting the X500 addresses for organization with 50-100 users is a pain.
So any assistance here will be highly highly appreciated.Hi,
The source and target site are similar at most parts. Both are running EX2010 and the Dc structure is similar at most part.
We're using an automation products that creates the mailboxes in the new site, so the only thing that get's broken is the autocomplete and calendar and which can be fixed if I'm copying the LegacyExchangeDN of each user and create it as X500 address.
The LegacyExchangeDN structure is also very similar at the two sites, for example:
New site: /o=HostedExchange/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=poli6c2
Old site: /o=HostedExchange/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=polib9f
So you can see, the only part that is changed during the migration is the users CN.
Anyway, I was able to create the required csv using this command:
Get-Mailbox -Filter {Emailaddresses -like "*domain.com*"} |select name,displayname,PrimarySmtpAddress,LegacyExchangeDN |Export-Csv "C:\details.csvBut I need some help in importing the details into the new site. -
HI to all experts,
i need help in devloping a command in wad using java script.
the command i want to create will provide me the option to send a certain wad URL (link) thru a message using outlook . the command needs to genrate the url from bi portal .
Thanks
AlexCurrent page URL
document.location.href
Sending an email
Here is some javascript that will dynamically generate a hyperlink for the user to click on. The body of the email will contain the page of the URL
var sHREF = "mailto:[email protected]?subject=Dynamic URL&body=";
sHREF = sHREF + document.location.href
sHREF = "<a href='" + sHREF + "'>";
sHREF =sHREF + "Send Email</a>";
document.write(sHREF)
(Sorry, this crappy online editor doesn't allow me to post nice code samples, so I have had to butcher it to get it to display here)
This, however, won't send it automatically. If you want to do that, then you'll need to do something like creating a hidden form on your page, populating an input value in the form with the page URL and then submitting the form. You can set as the action of the form a mailto recipient.
Hope this helps.
Cheers,
Andrew
Edited by: Andrew Lewis on Nov 19, 2008 1:30 PM -
EEM scripting assistance: Switch, router and AP CDP
We would like to create an EEM script which will let the switch populate the interface description based on the CDP neighbour, however, we want the script to only populate the interface if (and only if) the CDP is a Cisco wireless access point (AP), a Cisco Catalyst switch and a Cisco router. We DO NOT want the interface description to be edited if the CDP neighbour is a Cisco phone or a Cisco DMP (for example).
This is our EEM script:
event manager applet update-port
event none
event neighbor-discovery interface regexp GigabitEthernet.* cdp add
action 100 if $_nd_cdp_capabilities_string eq "Router" goto 200
action 110 elseif $_nd_cdp_capabilities_string eq "Switch" goto 200
action 120 if $_nd_cdp_capabilities_string eq "Switch" goto 200
action 200 cli command "enable"
action 210 cli command "config t"
action 220 cli command "interface $_nd_local_intf_name"
action 230 cli command "description $_nd_cdp_entry_name"
action 400 else
action 500 end
And this is a sample of our “sh cdp neighbor” output:
Switch#sh cdp n d
Device ID: Wireless
Entry address(es):
IP address: <REMOVED>
Platform: cisco AIR-CAP3602I-N-K9 , Capabilities: Router Trans-Bridge
Interface: GigabitEthernet0/8, Port ID (outgoing port): GigabitEthernet0.1
Holdtime : 146 sec
Version :
Cisco IOS Software, C3600 Software (AP3G2-K9W8-M), Version 15.2(2)JB, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2012 by Cisco Systems, Inc.
Compiled Mon 10-Dec-12 23:52 by prod_rel_team
advertisement version: 2
Duplex: full
Power drawn: 15.400 Watts
Power request id: 19701, Power management id: 2
Power request levels are:15400 0 0 0 0
Power Available TLV:
Power request id: 0, Power management id: 0, Power available: 0, Power management level: 0
Management address(es):
Device ID: 00:0f:44:02:c5:29
Entry address(es):
IP address: <REMOVED>
Platform: Cisco DMP 4310G, Capabilities: Host
Interface: GigabitEthernet0/3, Port ID (outgoing port): eth0
Holdtime : 157 sec
Version :
5.4
advertisement version: 2
Duplex: full
Power Available TLV:
Power request id: 0, Power management id: 0, Power available: 0, Power management level: 0
Management address(es):
Device ID: CALM040.mgmt.educ
Entry address(es):
IP address: <REMOVED>
Platform: cisco WS-C3750E-24PD, Capabilities: Switch IGMP
Interface: GigabitEthernet0/10, Port ID (outgoing port): GigabitEthernet1/0/22
Holdtime : 126 sec
Version :
Cisco IOS Software, C3750E Software (C3750E-UNIVERSALK9-M), Version 15.0(2)SE, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2012 by Cisco Systems, Inc.
Compiled Fri 27-Jul-12 23:26 by prod_rel_team
advertisement version: 2
Protocol Hello: OUI=0x00000C, Protocol ID=0x0112; payload len=27, value=00000000FFFFFFFF010221FF0000000000000023AC075300FF0000
VTP Management Domain: 'ACTEducation'
Native VLAN: 99
Duplex: full
Power Available TLV:
Power request id: 0, Power management id: 1, Power available: 0, Power management level: -1
Management address(es):
IP address: <REMOVED>
Device ID: 00:0f:44:02:b6:31
Entry address(es):
IP address: <REMOVED>
Platform: Cisco DMP 4310G, Capabilities: Host
Interface: GigabitEthernet0/2, Port ID (outgoing port): eth0
Holdtime : 169 sec
Version :
5.4
advertisement version: 2
Duplex: full
Power Available TLV:
Power request id: 0, Power management id: 0, Power available: 0, Power management level: 0
Management address(es):
Best Regards/Leoaction 221 regexp "^([^\.])\." $_nd_cdp_entry_name match hostaction 230 cli command "description $host"
Hi Joe,
So the EEM is going to look like this:
event manager applet update-port
event neighbor-discovery interface regexp GigabitEthernet.* cdp add
action 100 regexp "(Switch|Router)" $_nd_cdp_capabilities_string
action 110 if $_regexp_result eq 1
action 200 cli command "enable"
action 210 cli command "config t"
action 220 cli command "interface $_nd_local_intf_name"
action 230 regexp "^([^\.])\." $_nd_cdp_entry_name match host
action 240 cli command "description $host"
action 500 end
Is this correct? -
Script assistance please...
Hi Folks,
I'm trying to create a script to create a .DMG of a given directory, then SCP it to another machine.
The script below successfully creates the .dmg I need (with date appended), but I'm not sure how to identify the DMG just created, to then SCP it to another machine, and after that, to delete it from the /tmp directory.
This will run via cron job when completed (it's on a 10.4.11 machine)
Your help is much appreciated!
Lurch
#!/bin/sh
# this daily script archives Filemaker Databases, and sends them to the server
PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH
hdiutil create /tmp/FMP-databases-`date +%m%d%Y`.dmg -srcfolder /FileMaker Server 5.5/Databases
exit 0Here's the finished script, with huge thanks to BobHarris. I've created a few more variables at top to make it a little more portable:
#!/usr/bin/env bash
# this script archives a given folder into a compressed .dmg, appends a date onto the .dmg name, and and sends them to another machine
SOURCE="/Users/youraccount/yourfolder"
TMPFILE="/tmp/yourfolder-$(date +%Y%m%d).dmg"
# destination must be exact, absolute path on remote machine where backup is to be kept:
DESTINATION="/Volumes/Backups/backup-directory/"
SUBJECT="Success: Backup results `date`"
RECIPIENT="[email protected]"
export PATH=/bin:/usr/bin:/sbin:/usr/sbin
hdiutil create "${TMPFILE}" -srcfolder "${SOURCE}" >/tmp/$$
sts=$?
if [[ ${sts} = 0 ]]; then
echo "hdiutil create successful!!" >>/tmp/$$
# display size in human readable format:
echo `du -sch ${TMPFILE}` >>/tmp/$$
else
echo "hdiutil create FAILURE!!" >>/tmp/$$
SUBJECT="hdiutil FAILURE: Backup results"
fi
# if the hdiutil was successful, then copy the file to backup server.
if [[ ${sts} = 0 ]]; then
scp -r -E "${TMPFILE}" [email protected]:"${DESTINATION}"
sts=$?
if [[ ${sts} = 0 ]]; then
echo "DMG backup successful!!" >>/tmp/$$
else
echo "DMG backup FAILURE!!" >>/tmp/$$
SUBJECT="scp FAILURE: Backup results"
fi
fi
# Send mail. This assumes Postfix or another MTA is already working on your machine
mail -s "${SUBJECT}" ${RECIPIENT} </tmp/$$
# Clean up temp files
rm -rf "${TMPFILE}" /tmp/$$ -
Safari scripting, assistance please.
Hi there,
Is it possible to write an automating script for safari to open a link repeatedly over a certain period of time, ideally with set intervals.
Here's what Im trying to do,
My band is in a small competition on MySpace where the winner is the band with the most plays over two weeks, now if we cant script it, members of the band will be using a computer all day at work so they will be just hitting play all day anyway (maybe cheating but the other bands are doing it too so its only fair).
I know its a childish request, but hopefully someone wil be able to help!
ThanksSounds like a very bad plan.
The "hits" you're trying to get will not count as "new" and the server software would only send a "cookie" file to a new viewer.
Any repeated page load would not be included in any page "count" and could also be considered spamming for hits and then exclude your file from the competition.
Play better music (or play your best) and let the results fall where they may. -
EEM/Tcl Script Assistance Part3
Hello Community,
Attached is a script originally posted by Joseph.
When I apply the script I get the following error message:
R2(config)#event manager policy switchstats.tcl
Compile check and registration failed:policy file does not start with event register cmd: file
Tcl policy execute failed: policy file does not start with event register cmd: file
Embedded Event Manager configuration: failed to retrieve intermediate registration result for policy switchstats.tcl: Unknown error 0
I was wondering if someone could take a quick look and let me know what the problem is/
CheersHello Community,
I realised what I was doing wrong, so please ignore the original post.
However, I get the following error on line 22 when I run the script.
uk0149_SW2960_100Cheapside#tclsh switchstats.tcl
extra characters after close-quote
while executing
"puts $filename "switch, interface, packets input,bytes,no buffer,broadcasts,multicasts,runts,giants,throttles,input errors,CRC,frame,overrun,ignored,w..."
(file "switchstats.tcl" line 22)
Line 22 is:
puts $filename "switch, interface, packets input,bytes,no buffer,broadcasts,multicasts,runts,giants,throttles,input errors,CRC,frame,overrun,ignored,watchdog,multicast,pause input,input packets with dribble condition detected,packets output,bytes,underruns,output errors,collisions,interface resets,babbles,late collision,deferred,lost carrier,no carrier,PAUSE ,output buffer failures,output buffers swapped out"
Can you help?
Cheers
Maybe you are looking for
-
Dear Folks, I created a condition record for free goods in MBN1. It is an exclusive conditon type where the vendor will give me 1 free item of X for 3 items of X purchased. I am expecting a 2nd line item to appear automatically when I create the 1st
-
Internal mic problem my doing?
I have a MacBook Pro, mid-2010 model, Snow Leopard, OS 10.6.8, 2.4 GHz Intel Core 2 Duo, 4 GB memory 1067 MHz DDR3. My problem is with my internal microphone. I Skype once a week with my daughter and until 2 weeks ago, the internal micrtophone worke
-
i made a dual boot of windows 7 and mac os x lion in my macbook pro .i installed m icrosoft support software also. now, can i install windows updates? do i turn on the automatic updating of updates?
-
How do I get rid of a search engine that has taken over Firefox?
I have a problem similar to the "Abuchak" problem listed in your forums. This is something different though. When I am at Yahoo or Google, I click a link and it takes me to another search listing. Sometimes it takes me to various sites where Avast (v
-
Hi Friends, Please clarify me the difference between Payment terms and Inco terms (PO-Header data). I have gone thru SAP help, but I am not clear. Please help. Best regards, Raman.