Go Premium for a chance to win a PS4. Enter to Win

x

Scripting Languages

26K

Solutions

20K

Contributors

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.

Share tech news, updates, or what's on your mind.

Sign up to Post

I am using Perl to connect to Oracle database to retrieve rows.

The code fails with the error when attempting to assign bind parameters to 3 variables derivdate, group and row_number. The code works CORRECTLY and outputs data ONLY when the 3 values are hard coded in the query without the bind param assignments.


my $gen_text = $dbh->prepare(qq(SELECT col1, col2 FROM region WHERE STATUS = 'N' AND PARTITION_KEY IN (SELECT col_1 AS part_key FROM Sched  WHERE derivdate = to_date(?,'YYYY-MM-DD') and group = ? and row_number = ?)))    
               						or die("Could not get data from table '$_'".DBI->errstr); 
               						 
$gen_text->bind_param(1,$derivdate); 
$gen_text->bind_param(2,$group); 
$gen_text->bind_param(3,$row_number); 
 
$gen_text->execute($derivdate, $group, $row_number); 
 
 
my @firstrow; 
my @columns; 
 
 
if (exists($$cols[0])) { 
	   
        foreach my $col (@$cols) { 
            my ($name) = $$col[0]; 
            $name =~ s/\s+//g; 
            push @columns, $name; 
        } 
    } else { 
    	   
        my $rc  = $gen_text->fetchrow_hashref() or $nodata = 1; 
        if ($nodata) { 
        	print("  - No data found in table '$_' ".$gen_text->errstr());   -- Line 86
        	exit(0); 
        } 
        my @row = @{$gen_text->{NAME}}; 
        @$cols  = @row; 
     
        foreach my $col (@$cols) { 
            my $name = $col; 
            $name =~ s/\s+//g; 
            my $data = $rc->{$name}; 
            push @firstrow, 

Open in new window

0
Free Tool: IP Lookup
LVL 11
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Hello Experts,
how does make a bat file for continuous Ping multipal IP with background Colour changes ?
for example:-
start ping -t 192.168.207.11 -l 0
start ping -t 192.168.207.12 -l 0
start ping -t 192.168.207.13 -l 0
start ping -t 192.168.207.14 -l 0
start ping -t 192.168.207.15 -l 0
0
I am using Perl version 5.8.8 on Windows.

I have below incomplete perl script to read from a oracle 11g database table.

# This script connects to an oracle database, reads columns from region based on a selection criteria and output records in a csv 
# 
use strict;
use DBI;
use warnings;
use File::Copy;
use Text::CSV;

my $dbh = DBI->connect("dbi:Oracle:$db",$user,$pw)
              or die "Database connection not made: $DBI::errstr";
{
my $sth = $dbh->prepare("SELECT * FROM region");
$sth->execute;
my $names = $sth->{'NAME'};
my $tbl_data = $sth->fetchall_arrayref;
print join "\n", map { join(',', map { "\"$_\""' } @$_ } @$tbl_data;

$dbh->disconnect(); }

Open in new window


I am new to Perl and not sure how to achieve the following:

a. restrict the select statement with a where clause and use the below where clause condition as an input to the script.
b. update statement (as below) once the file is written to a csv.

 The select statement would be as below
select region_date, cntr_name  from region  
where cntr_name in ('US' , 'CAN')  
and flag = 'Y' and part_key =  
(select ('S_' || v.tsched || '_' || v.cgroup) as partition_key   
from rgvars v	 
WHERE v.regdate = -- "input parameter"														and v.cgroup = -- "input parameter" 
and v.dnumber = -- "input parameter ");
--
update region
set code = 'N' -- once the file is written out in a csv format

Open in new window


The desired output will be in a dump of the region table in a csv format with headers.


Thanks,
0
I have this old batch file that I used to upgrade a software and since it is time for another one I have tried creating a GPO and assigned it under User Configuration>Windows Settings>Logon.

But when testing with a user logging on the batch file wont run but when manually clicking the file it runs perfectly fine!

Here is the code:  xcopy "Source" "Destination" /S /C /I /H /R /Y

Users have a full time mapped drive from where the source file is copied to the local drive C:\Folder

Note that robocopy is the same and doesn't run automatically.
0
When the PowerShell command set-executionpolicy unrestricted is run from the PowerShell will this permanently set the execution policy as unrestricted or does this unrestricted access only remain in effect until the PowerShell session ends?
0
I want to modify this script, since the output in the body of the email is actually showing
the <br> and is not producing the ouput on separate lines when it sees the <br>.. but keeps everything together.

Thanks for your help.


$Line = Get-Content "C:\Programs\ABC\ABCTemp\New.txt"
 #Send Email
$EncryptedCredential = "C:\secred\info.txt"
$EmailUsername = "mail@office365.com"
$EncryptedPW = Get-Content $EncryptedCredential | ConvertTo-SecureString
$Credential = New-Object System.Management.Automation.PsCredential($EmailUsername, $EncryptedPW)
$EmailFrom = "mail@office365.com"
$EmailTo = "<mail2@office365.com>"
$EmailSubject = "Info"
$EmailBody = ($Line -join "<br>")
$SMTPServer = "xxx.xxxx.com"
$SMTPPort = 000
 
$SMTPSsl = $true
 
$param = @{
    SmtpServer = $SMTPServer
    Port = $SMTPPort
    UseSsl = $SMTPSsl      
    Credential = $Credential          
    From = $EmailFrom    
    To = $EmailTo              
    Subject = $EmailSubject
    Body = $EmailBody
 
   
}
 
Send-MailMessage @param
0
Hi,
Can someone tell me script to get all the computer names in AD  in specific OU with Last logon date.
0
Hi Experts,

I'm trying to use FileCopy command to copy a file from a local folder to a network location.
When I copy manually from the windows explorer it works fine.
However when I want use it thru FileCopy command I get the attached error

Assuming this must be given special permissions, any suggestions?
Untitled.png
0
Hello,

***UPDATE****
As I use OpenOffice on Windows 7 for manually making the work that follows, maybe that an OpenOffice Guru can find a better solution than a Perl script, so I've added also OpenOffice in the topics
***************

I'm searching for a good solution for converting Windows xlsx/xls files (Windows 1252 WinLatin 1) in csv (UTF-8) files with a script like:

perl script.pl<file.xlsx>file.csv

my environment is Windows 7 with ActiveState Perl 5.24.0

The script should also "cut-off" the first line & the first column of every Excel spreadsheet

Thanks a lot,

Fabiano
0
can I use any script in AD to do following as there are 200 in number of users
Make the Everyone FULL CONTROL on the share.
  REMOVE Evenyone from the list on the security tab
  ADD the groups (or users if you must) to the security tab and assign them the permissions you want them to have
0
Free Tool: SSL Checker
LVL 11
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Hello Folks,
I have a list of users first name last name ( john doe )...is there any command that will retrieve me their ntid?

thanks for looking
1
Dear experts, I create a daily task to start a powershell script as below, to delete some files but it did not work. The history show nothing special except 0x103

del C:\Test1\*
Remove-item C:\Test2\A\*

Open in new window


Please check and suggest. Many thanks in advance.
history.PNG
history1.PNG
0
Hello Folks,
I'm trying to create a bash script and I need to translate this to .SH format

pwd #example command
if [ $? -ne 0 ] 
then echo "bad input of the command try again"  #the command should re-do*
else  fi
echo "next command" #more commands continue with the rest of the bash

Open in new window


*I just don't know how to loop it, i know if I was  in batch then i can set up routines but i'm not sure if those are possible to apply here
0
I am playing with a puzzle program where certain puzzle pieces will have information to share, and those are the ones with a "dog-ear" on the upper corner.

Sample
Those with a dog-ear will respond differently to user interaction and each will have images, videos and/or help text, explaining what's so special about the selected  puzzle piece. There could also be a left-click or a right-click which opens an enlarged version of a given puzzle piece, so the user can get a close-up.

I need some ideas about how to present this information to the user. I am not sure what types of click or clicks would be used to bring up what probably would be a menu of options.


Suggestions?
0
Here i the CSS I use to create the dark corner in the upper-right.


.dog-ear {
	position: absolute;
	top: 0;
	right: 0;
	height: 10px;
	width: 10px;
	background: linear-gradient(45deg, #333 0%, #333 50%, #fff 50%, #fff 100%);
}

Open in new window



But It sometimes looks choppy.

Choppy line
Is there a different way to do this?
0
In Vmware VM and Templates , I have several folders, and in each folder there are multiple VMs.
I want to know to which Host and Cluster each VM belongs to
is it possible to get the list through Powercli ? or it needs a script?

for instance:

VM Name,        Cluster Name,        ESX Host Name
VM 1		    Clust1	                    ESX1
VMX                    ClustA                    ESXB  

Open in new window



Thank you
1
I added a class to a div, and verify the booelan's working.  But, the ng-class is failing.

    <div ng-class="{ 'dog-ear' : isDogEared }"></div>

Open in new window


Inside the Typescript template I have:
@Output() isDogEared:boolean;

  dogEarIndexes: number[];

  constructor() 
  { 
    this.dogEarIndexes = [ 1,3,5 ];
  }

  ngOnInit() {
    this.imageFilename = "PuzzlePiece_Maps_" + (this.value.id + 1).toString() + ".gif";
    
    this.id = this.value.id;
    this.isDogEared = this.dogEarIndexes.indexOf(this.id) > -1;
    console.log('Id:'+this.id+" - " + this.imageFilename + " isDogEared="+ this.isDogEared.toString());    
  }

Open in new window


and the page does not generate any errors, and I verified the boolean values are properly set in ngOnInit()

Booleans Work OK

What am I missing?
0
I had this question after viewing Modifying PowerShell script to list last 5 Event ID not working ?.

Hi All,

When I modify the script to get the Exchange server events, somehow it does not show it in the first column ?

$objExcel = New-Object -comobject Excel.Application
$objExcel.Visible = $True
$objWorkbook = $objExcel.Workbooks.Add()
$objSheet = $objWorkbook.Worksheets.Item(1)
$objSheet.Cells.Item(1,1) = "Server"
$objSheet.Cells.Item(1,2) = "LogName"
$objSheet.Cells.Item(1,3) = "Time"
$objSheet.Cells.Item(1,4) = "Category"
$objSheet.Cells.Item(1,5) = "ID"
$objSheet.Cells.Item(1,6) = "Source"
$objSheet.Cells.Item(1,7) = "Message"
$objSheetFormat = $objSheet.UsedRange
$objSheetFormat.Interior.ColorIndex = 19
$objSheetFormat.Font.ColorIndex = 11
$objSheetFormat.Font.Bold = $True

$Row = 2

$Servers = Get-ExchangeServer

foreach ($Server in $Servers) {
    foreach ($Log in @("Application", "Security", "System")) {
        $Events = Get-EventLog -LogName $Log -Computer $Server -Newest 5 -ea Silentlycontinue | Where-Object {$_.EntryType -in 'Error', 'Warning'} | Sort-Object Source
        foreach ($Event in $Events) {
            $objSheet.Cells.Item($Row, 1).Font.Bold = $True
            $objSheet.Cells.Item($Row, 1) = $Server
            $objSheet.Cells.Item($Row, 2) = $Log
            $objSheet.Cells.Item($Row, 3) = 

Open in new window

0
Hi All,

I got this script that used to work to report the last 5 error & warning from multiple Exchange Server then write it into Excel.

Somehow this is not working ?

$objExcel = New-Object -comobject Excel.Application
$objExcel.visible = $True
$objWorkbook = $objExcel.Workbooks.Add()
$objSheet = $objWorkbook.Worksheets.Item(1)
$objSheet.Cells.Item(1,1) = "Server"
$objSheet.Cells.Item(1,2) = "LogName"
$objSheet.Cells.Item(1,3) = "Time"
$objSheet.Cells.Item(1,4) = "Source"
$objSheet.Cells.Item(1,5) = "Message"
$objSheetFormat = $objSheet.UsedRange
$objSheetFormat.Interior.ColorIndex = 19
$objSheetFormat.Font.ColorIndex = 11
$objSheetFormat.Font.Bold = $True

$row = 1

$servers = Get-ExchangeServer

foreach ($server in $servers)
{
  $row = $row + 1
  $AppLog = Get-EventLog -LogName Application -computer $server -Newest 5 | Where-Object {$_.EntryType -like 'Error' -or $_.EntryType -like 'Warning'} | Sort-Object Source
  $SecLog = Get-EventLog -LogName Security -computer $server -Newest 5 -ea Silentlycontinue | Where-Object {$_.EntryType -like 'Error' -or $_.EntryType -like 'Warning'} | Sort-Object Source
  $SysLog = Get-EventLog -LogName System -computer $server -Newest 5 | Where-Object {$_.EntryType -like 'Error' -or $_.EntryType -like 'Warning'} | Sort-Object Source
  foreach ($Cat in $AppLog,$Syslog,$Seclog)
  {
    if ($cat -is [array])
    {
      if ($AppLog -contains $cat[0]) {$Catname = "Application"}
      if ($SecLog -contains $cat[0]) {$Catname = 

Open in new window

0
New feature and membership benefit!
LVL 11
New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Please provide me with the command line or power shell commands to enable & disable network discovery within Windows 10.
0
I have an Access DB, in it I have an authentication form for users, I want to import data using a powershell script, but when the script opens the DB fails to import because the form does not enter the access data. My code is this and I could not make it work

$database = 'D:\db.accdb'
$Acc = New-Object –comObject Access.Application
$Acc.Visible = $false
$Acc.OpenCurrentDataBase($database)
$Acc.DoCmd.OpenForm('Form_Login_bd')
$AccForm = $Acc.Forms.item('Form_Login_bd')
$AccForm.Controls.Item("txt_login").value = "Test_Admin"
$AccForm.Controls.Item("txt_contrasena").value = "Test_Admin123"
.
.
.
script to import data
.
.
.

Any idea how to solve it
0
Hello all,

I need to build a table that has which cost center should be mapped different service codes.  

I have a list of almost 35K records that I need to map.  In a perfect world, I could just say 000001 to 000100 belongs to 5010 then 000101 to 000200 belong to 5020.  Well that does not work as I have some ranges within a range that belongs to a different cost center or in one section every other code changes to a different cost center really only 2 (000300 = 5040, 000301 = 7485, 000302 = 5040, 000303 = 7485 and so on.) I still would like to have some SQL code that would read in the first record say OK here is the start of my range and it goes to cost center xxxx then look at the next record it is the same cost center so it is the top of the range, go to the next one it is the same cost center so it is now the top of the range.  Finally, the cost center changes so it is the start of the new range for the new cost center and I do the same logic again.  Does this sound right?  I just need a little help getting started.

*** UPDATE ***
10/19/2017
I built the table manually but I would still like to create a script in SQL or VBA that will take my listing of codes and map a range out for each section.  The listing is around 25,000 lines and my range table is about 4,000 lines.  It took me a few hours to create it.  Creating the range in SQL is my preference, but I can do VBA as well.  Thanks again.


10/18/2017
I have started creating a VBA Function in Access to …
0
I hope to post a sample application which displays a problem I am having and need to find what aspects I need to create for this. It would mainly be for posts on EE but could be used to share my code for other purposes.

Can you suggest one?

I create a GitGub account and use Git to put the latest version of my site to GitHub.

What if two people want to make an alteration to the code I post there? When someone makes a change, is there a way to auto-fork the repo?
0
I received an excellent response to my question of deleting files based on match and amount of days old.   Initially I was told they should delete based on age of file and if they have a matching .xxx file.    That has since changed to:   files should delete based on if there is a matching .xxx file and only if it is older than 3 days (regardless if the other files are older).  

The script help I received before from Bill Prew looks like:

@echo off
setlocal EnableDelayedExpansion

rem Define folder to process
set "BaseDir=C:\Users\ad9f2p\TEST CLEANUP"

rem Look at each .XXX file
for %%A IN ("%BaseDir%\*.xxx") do (

  rem Reset delete flag, and check all files with this same base filename
  set DeleteFlag=Y
  for %%B IN ("%BaseDir%\%%~nA.*") do (

    rem Get dyas since last modified (using VBS helper routine)
    set Fileage=0
    for /f "tokens=*" %%C in ('cscript //nologo fileage.vbs "%%~B"') do (
      set Fileage=%%C
    )

    rem If any file found less than 3 days old, do not delete the group
    if !FileAge! LEQ 3 (
      set DeleteFlag=N
    )
  )

  rem If all files found older than 3 days, delete them all
  if "!DeleteFlag!" EQU "Y" (
    ECHO del /q "%BaseDir%\%%~nA.*"
  )
)

Open in new window

Can I add a nested If statement to the section:

    rem If any file found less than 3 days old, do not delete the group
    if !FileAge! LEQ 3 (
      set DeleteFlag=N
    )

Open in new window

Can I check the file age on only the .xxx files and delete the corresponding files that match then, only if the .xxx file is older than 3 days?   I've tried doing this by rearranging the logic, currently it deletes everything with a .xxx file:    What am I missing here?


Open in new window

0
I need a script to press automatically OK every 2 min, see snapshot bellow and here the script i use, not working:

Set wshShell = CreateObject("WScript.Shell") 

Do 
    ret = wshShell.AppActivate("Remote Desktop Connection") 
    If ret = True Then 
        wshShell.SendKeys "{ENTER}" 
        Exit Do 
    End If 
    WScript.Sleep 500 
Loop 

Open in new window

error.JPG
0

Scripting Languages

26K

Solutions

20K

Contributors

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.