Questions tagged [scripting]

A form of computer programming that — in the context of system administration — lends it self well to automating tasks.

Filter by
Sorted by
Tagged with
1
vote
2answers
2k views

Allow php and python script with apache but still have a secure server

problem "solved"? after backtracking where the permission first stops, the permission denial suddenly went away for no reason. I am building a webpage where the user must have the possibility to send ...
0
votes
1answer
17 views

Amazon EC2 only running one http script

I'm running a python script to scrapping a page in my EC2 server using screen linux though a SSH connection. My EC2 account is the free tier offered by them. Every time I try to run another script (...
1
vote
2answers
6k views

Sending email after successful mysqldump

I've a script which will take backup of mysql db through mysqldump. I'd like add another option in this script to send an automatic email if the dump is successful or failure. Here's the script: #!/...
0
votes
1answer
28 views

Using PsInfo with a Timeout Procedure (or piping through PsExec?)

We have a problem with people in our company leaving their computer running 24/7 even over weekends. Our corporate policy is to shut down when not in use but that doesn't always happen. So what we ...
48
votes
6answers
167k views

How can I fully log all bash scripts actions?

From my script output I want to capture ALL the logs data with error messages and redirect them all to log file. I have script like below: #!/bin/bash ( echo " `date` : part 1 - start " ssh -f ...
1
vote
1answer
2k views

Obtain device driver version and associated GUID using PowerShell?

Right now, I am getting two separate objects A Win32_NetworkAdapter WMI object A Win32_PnpSignedDriver WMI object In my previous scripts, I've made sure I was calling separate objects, and relating ...
3
votes
2answers
1k views

What do you have in /usr/local/sbin/adduser.local?

I'm looking for example additional configuration done on new user creation, the kind of stuff that goes beyond /etc/skel. For example, has anyone written a script to set public_html set-GUID?
1
vote
1answer
35 views

Pemission denied when I try to create a new file with a script

So, I have a bash script "get-data.sh that runs other two python scripts #!/bin/bash scripts=/root/scripts datos=/root/zabbixdata fecha=$(date +"%Y_%m_%d") sudo $scripts/filesystem.py > $datos/...
0
votes
2answers
3k views

Automate app pool recycling of an Azure Cloud Service Web Role

How can I script (e.g. using PowerShell) the action to recycle the app pool of a web site hosted in a Web Role on Azure Cloud Services? Only one instance of the cloud service is running (used for ...
9
votes
2answers
5k views

Changing physical path on IIS through appcmd isn't activated

We have come across an issue on IIS 7.5 where we have a simple deploy system which consists of the following: Create a zip-file of new webroot, consisting of three folders: Api Site Manager This is ...
48
votes
9answers
115k views

Tool to test a user account and password (test login)

Yeah, I can fire up a VM or remote into something and try the password...I know...but is there a tool or script that will simulate a login just enough to confirm or deny that the password is correct? ...
1
vote
2answers
7k views

Create a self-signed certificate on Windows Server 2008 R2 with powershell v2.0

I'm trying to create a self-signed certificate using power shell. I have tried using import-module PKI but seems like it's supported on powershell v3.0 onward .Is any other way I could create a self-...
2
votes
3answers
3k views

password check in bash script calling on expect

Background: I have to copy a file from one server, to over 100 servers in a test environment. once the file is copied, it requires to have the permissions on the file changed/verified. These are all ...
0
votes
1answer
5k views

Automatic alert/notification of calendar items added to Public Folders

We currently use Public Folders with Exchange 2010. We have a series of shared calendars throughout the organization. Some of the items posted require us to set up devices (video conferencing for ...
0
votes
0answers
56 views

PowerShell Script to remove Security Permission from Folders

Using PowerShell, I am looking for a little help to remove certain built in domain accounts from a folder under the users Home folder. I have already written code to remove inheritance, but I can't ...
26
votes
7answers
24k views

Bash Scripting: Require script to be run as root (or with sudo)

I'm trying to write a bash script (in Ubuntu) that will backup a directory using tar. How can I do a check in the script so that it can only be run as root (or with sudo)? For instance, if a user ...
1
vote
1answer
15 views

Get-VM command with -Location parameter returns one result then error

i'm writing a powerCLI script and i'm facing a strange behaviour. I use connect-VIserver with administrator@vsphere.local account to connect to my VCSA 6.7 U2 server. If i use Get-VM cmdlet without ...
-1
votes
1answer
17 views

How can I recursively unarchive all files that are bzipped2?

I have a folder. In this folder I have a lot of other folders. In folders I have bzip files and non-bzip. How to unarchieve all bzip2 files in same directory where they are ?
2
votes
1answer
983 views

Amazon S3 Website & MySQL Backup

I have a website (a digital asset management system/gallery - http://www.resourcespace.org) that has a huge amount of images. The total size of the website, including the images is approximately 6gb. ...
1
vote
2answers
238 views

Change Registry Key Permissions Access Control List using only Command Prompt

I am trying to change the Access Control permissions on a specific registry key i'm generating using a batch file. I try using regini.exe to pull the configuration from a .ini file and run into ...
2
votes
1answer
1k views

lftp mirror leaves empty folders on remote

My script is set up with this for lftp lftp -p 2218 -u $login,$pass sftp://$host << EOF set mirror:use-pget-n 5 mirror -c -P5 --depth-first --Remove-source-files --log=/home/dog/...
6
votes
2answers
65k views

How to edit Local Group Policy with script?

I have to set the local Group Policy settings and the the local Security Policy for a couple of machines which are not in a Windows Domain. Until now, I've done that by manually setting the keys in ...
2
votes
1answer
1k views

vmware thin disk usage powercli

I want to ask a question about thin provisioning. get-vm commandlet can easly give us real space used by a vm totally. Assume that you have a virtual machine which has more than one thin disk. If ...
0
votes
1answer
1k views

Powershell error when adding filepath

The script looks like this: $searchOU='ou=Servers,dc=mydomain,dc=NET' Get-ADComputer -filter * -SearchBase $searchOU | Foreach-Object { $server = $_.Name ([ADSI]"WinNT://$($_.Name)/...
2
votes
2answers
6k views

What shebang for Anaconda Python on my directory of Server

I have anaconda python distribution in ~/anaconda/bin/python but what shebang can I use to call this version of python instead of the old one that is default on the server? # /opt/python/bin/python2....
0
votes
1answer
45 views

.bat script that moves file to a folder and adds date

I've pieced together this script to try and move a file from a folder to another, and add a date to the end of the file. It worked once, but hasn't worked since. This is my first script, and I was ...
0
votes
0answers
30 views

Keepalived - Failover when both vrrp AND track script failed

I've made a track script which is ran at each check by keepalived. When the VRRP check is failing, the BACKUP node become MASTER, even if the track script is returning 0 status (good one). I just ...
0
votes
3answers
6k views

How to script sql server 2005 database with data?

I use sql server 2005 as my database for my web application.... I generated scripts of the database by, Database->Right Click->Tasks->Generate Scripts I can script all my Tables,Stored ...
24
votes
9answers
60k views

How do I read multiple lines from STDIN into a variable?

I've been googling this question to no avail. I'm automating a build process here at work, and all I'm trying to do is get version numbers and a tiny description of the build which may be multi-line. ...
0
votes
0answers
33 views

Interactively bypass/skip part of PowerShell script

I have a script that is made up of many steps. I want it to run from start to end most of the time. Sometimes, I want to skip one of the steps. I'm looking for a "continue by default unless user ...
0
votes
1answer
2k views

'systemctl restart service' not working on CentOS 7

I have a custom service managed by an init script in /etc/init.d and, after upgrading to CentOS 7, with systemd, 'systemctl restart service' is not working correctly. I need to execute two times '...
0
votes
1answer
1k views

Can't figure out how to get started with powerdns-recursor lua scripting

I have a server (Ubuntu 12.04) where I run powerdns-recursor. I'm trying to add some logic to certain requests and have got my target set on lua scripting for powerdns. I don't seem to be able to ...
0
votes
0answers
33 views

How store the result of the operation in each node

I used to SLURM My SLURM configuration is One Master Node , Two Compute Node I want to Store the result of the operation in each node. So I try to this Script #! /bin/bash #SBATCH -J testing #...
1
vote
1answer
1k views

SNMP Custom Script Execution in Win 2008R2

I'm trying to execute a custom Script that is readable from SNMP service. Let's try to explain my purpose. I have a Win2008R2 server I have a PowerShell Script that "echo" something and return an ...
2
votes
1answer
8k views

Copy-item with multiple filter

How can I use copy with multiple filter values? For example, it works if I specify only 1 value to filter (*.jpg) Copy-Item -Path Y:\TEST -Recurse -Filter *.jpg -Destination D:\Users\MS5253\Desktop\...
0
votes
1answer
44 views

While schedule below script through crontab receive incorrect output date format is going wrong

PFB script dd=$(perl -e 'use POSIX;print strftime "%Y%m%d",localtime time-172800;') Date=$(perl -e 'use POSIX;print strftime "%d%m%Y",localtime time-172800;') for i in `cat /path/Path_CDR.txt` do cd ...
0
votes
1answer
1k views

How to reference Domain-Admins with icacls?

I need to reference the "Domain-Admins" group in a batch file. The line in question looks like this: icacls "test\folder" /grant mydomain.com\Domain-Admins:F ... and works as expected. But how do I ...
1
vote
1answer
107 views

Powershell Get-Netadapter varible pass to Set-DnsClientServerAddress

Good day everyone, Trying to write a simple script that will find the friendly name of the Ethernet Adapter on a given machine and pass this string to the cmdlet 'Set-DnsClientServerAddress' so that ...
26
votes
13answers
76k views

Need leading zero for batch script using %time% variable

I came across a bug in my DOS script that uses date and time data for file naming. The problem was I ended up with a gap because the time variable didn't automatically provide leading zero for hour &...
0
votes
1answer
1k views

Disable “Windows Firewall with Advanced Security” for all profiles(Domain,Public,Standard) in local GP using script help! Windows 7 Clients

We need Windows7 with windows firewall to be turned off , so the GOLD image has windows firewall turned off for all profiles(Domain,Public,Standard) and Windows Service disabled No the same GOLD ...
4
votes
3answers
1k views

How do I launch a command on a remote computer with an invalid domain trust? (using local creds)

I intend to use WMIC to reset the trust of a machine that is remote, and off the network. All of the following variations result in an "access denied": The following works fine: net use \\patterson-...
2
votes
1answer
2k views

Script to List all Desktop and Laptop Model for Server 2008 Domain

Is there any way I can list all the desktop and laptop model? There is no naming convention and I'm having difficulty differentiating laptop and desktop in our environment. I have already tried to ...
1
vote
1answer
1k views

How to auto-run batch file as specific user (not scheduled task, not a duplicate)

I am an enterprise admin (Sr. Network Engineer), but my team does not manage Active Directory, so I am a little unfamiliar with policies and what is required to do what I am trying to achieve, and ...
0
votes
1answer
53 views

Removing empty List in output as result [closed]

I have a simple script as following: import re wanted_line = [] with open('lines.txt','rt') as myfile: for myline in myfile: wanted_line = re.findall('ticket/\d+',myline) print(wanted_line[:...
0
votes
1answer
1k views

Queue VMware Virtual Machine vMotion using powercli

I wrote this quick Powershell script where it queues vMotion of VMs and runs only 4 vMotion tasks at a time. I thought this might help someone, so you are free to modify the code as per your like. We ...
2
votes
1answer
31 views

Faster way to add IP scopes to Item Level Targeting?

I have a GPO with printers mapped via the user preferences. Each printer needs to be item-level targeted only to computers in a specific IP range. I have a list of about 92 ranges that need to be ...
4
votes
3answers
14k views

Can't Get PSExec to work with Powershell

Last week I developed a script that would check if psremoting was enabled on specified machines. This week I began working on a script that would enable psremoting on specified machines but I can't ...
4
votes
5answers
14k views

Test for existence of an AD object in PowerShell using only Microsoft-provided cmdlets

I want to test for the existence of a computer account in Active Directory with PowerShell using only tools from Microsoft. Using Quest AD cmdlets, I can do this: if (!(get-qadcomputer $name)){ ...
0
votes
1answer
28 views

Is running a script a process? [closed]

I run ./install.sh and I tried to background it to be able to close the ssh session. But after running bg the process is again outputting to the terminal. Also, I don't see anything with jobs. ...
12
votes
6answers
35k views

How to parse and convert ini file into bash array variables?

I'm trying to convert an ini file into bash array variables. The sample ini is as below: [foobar] session=foo path=/some/path [barfoo] session=bar path=/some/path so these become: session[foobar]=...