A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

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
0
votes
0answers
3k views

Changing WinRM settings from Script

I am trying to change winrm's allow basic authentication property from command line. Following is my command winrm set winrm/config/client/auth @{Basic="false"} I get a message that this is ...
5
votes
2answers
383 views

how to use powershell object properties directly without typecasting and spliting?

I have created a small script to transfer value of Active directory pc attribute called pssfulllocation from one pc to anoter pc.. To achieve this I have to use typecasting + splitting.. Here is ...
-1
votes
2answers
451 views

Availability of file for each user directory on bash

I have an idea, how to check availability of "id_rsa.pub" for each user in home directory. But something does not work. My script: #!/bin/bash users=`ls /home/` for i in "$users"; do if [[ -f "/...
0
votes
1answer
2k views

logrotate when size reaches 10M

Please kindly advise/assist. I want to set up logrotate that does the following: when the log file size reaches 10M,the file is rotated and also there is no keeping of older compressed log files. I ...
-1
votes
1answer
411 views

one script to monitor incoming ssh connections to the server

I want to make a script to monitor incoming ssh connections to the server. Try ForceCommand in sshd_config but it will not let me in if I put it there my script. Match User * X11Forwarding no ...
1
vote
1answer
760 views

Ubuntu - adduser / useradd both ask for password to be set, can force a script to bypass this?

I have a script that works fine on Centos because useradd doesnt require a password to be set there and then, but the same script doesnt work on ubuntu servers as it requires this info. I ideally ...
3
votes
1answer
1k views

import list of pcs using import-Csv and change attribute using powershell script

Im trying to write a powershell script to change attribute called "comment" in a list of pcs using csv and import-Csv. Here is my script $computers=Import-Csv -Path "C:\sds.csv" foreach ($...
1
vote
1answer
285 views

NetworkManager up scripts running twice

My system, Ubuntu 16.04, uses NetworkManager. In order to hook an interface up event I have placed a script in /etc/network/if-up.d/. The head of the script looks like: #!/bin/bash NETIF="enp2s0" ...
0
votes
2answers
78 views

Newbie Sys Admin - Bash Script Assistance

I am a new sys admin who is learning the role as I go. I have a bash script here that I cant get to work. This is just a test script as its my first one so I know setting authorized_keys to 777 is ...
0
votes
0answers
118 views

Nagios php script to read iostat values

I'm working on a php script(nagios plugin) to read r/s,w/s,rMB/s,wMB/s,%util from the iostat command, e.g. #iostat -xm sda avg-cpu: %user %nice %system %iowait %steal %idle 1.05 0....
1
vote
0answers
27 views

Make one machine look like the rest regarding packages

I've been given the daunting task of deploying one "pristine" machine's packages to the rest of them - about 120 machines in total. All of the machines are running CentOS 6.8. The power users have ...
1
vote
1answer
96 views

Delete all folder not containing filename matching glob/regex

I want to do the following. I have depth 2 file hierarchy like this: A | B | | g | | h50000 | C Where A, B, C are folders. I want to delete all folders without files matching specific patters, (in ...
6
votes
2answers
490 views

Query Powershell Error Object Time Occured

Powershell error objects contain a lot of data but I can't seem to track down the time of occurrence for a given error. Using $Error[0] | fl -f retrieves a lot of information but none that appears to ...
1
vote
2answers
178 views

Bash script aborting after defining lsb functions

I'm currently trying to get a script to work, which needs to define some LSB functions. This is happening here: echo "step 1" # Read configuration variable file if it is present [ -r /etc/default/$...
0
votes
1answer
58 views

Find old files in directory

I'm writing backup rotation script, that suppose to take all files older then 5 days and delete them. Problem is that i've got some weird search results. for example: [root@spr1-nas01 storage]# date ...
1
vote
0answers
926 views

Check microphone level and change accordingly via script

I am trying to check what the existing volume on client workstations is and set to x (let's say x = 16.5). I figured out how to set the volume via cli which is using nircmd. To be specific: nircmd....
0
votes
1answer
91 views

AWS ELB - how to attach the latest/newest snapshot automatically?

I'm really new to AWS ELB and I'm reading about how to automatically mount an EBS volume from a snapshot via the ebextensions script. I've found this post as a reference: https://aws.amazon.com/blogs/...
0
votes
1answer
399 views

How to show lines where uniq more than 3

I have a file, where i should make "uniq" and show result. My file: 178.57.66.225 fxsciaqulmlk 178.57.66.225 fxsciaqulmlk 178.57.66.225 fxsciaqulmlk 178.57.66.225 faaaaaa11111 178.57.66.215 ...
0
votes
4answers
3k views

Grep by block of text\lines

I have the text, that contains some lines. So, i need to make GREP of several lines. For example, i have repeating text and i should GREP get lines, that have this repeating key-words. grep -o "test|...
1
vote
1answer
54 views

std output and error from functions

Is there a way to get the standard output and estandard error from the functions inside a bash script? This is what "I thought" I was trying to accomplish with my script: #!/bin/bash LOGS="tmp/sync....
-2
votes
1answer
463 views

Script to search bots from log file

I have a little log-file, where i should find the bots. File: Mon, 22 Aug 2016 13:15:39 +0200|178.57.66.225|fxsciaqulmlk| - |user logged in| - Mon, 22 Aug 2016 13:15:39 +0200|178.57.66.225|...
0
votes
2answers
100 views

Replace a string once another string has been found

I'm programmatically building boxes, but I need to update a .repo file for PHP which has the following contents: # Repository: http://rpms.remirepo.net/ # Blog: http://blog.remirepo.net/ # ...
0
votes
1answer
848 views

TrimStart() improperly truncates string

I wrote a script to backup bitlocker keys to Active Directory. The works great unless the Password ID starts with 'D'. Here is script #Get recovery info $recoveryinfo = manage-bde -protectors -get c: ...
0
votes
1answer
1k views

batch file to install application (Adobe Reader)

I previously used ninite to install this. However, this is no longer supported through ninite anymore. I usually install this manually but I know where a way to automate this using a batch script of ...
0
votes
2answers
92 views

Execute command on multiple files

I need to execute jpeg-recompress on thousands of files. I've tried: for image in *.jpg; do image2=${image%.*}.jpg; ./jpeg-recompress /path/to/images/$image /path/to/images/$image2; echo "...
0
votes
1answer
38 views

How create directory structure with permissions from web?

I have a directory structure in a shared folder with specific folder permissions for making projects in a Active Directory Domain like \server\shared\Projects\Project1, \server\shared\Projects\...
0
votes
1answer
65 views

Need script to replace TEXT in selected files

Environment Windows 10, C:\Folder_With_VMXfiles, installed sed for windows Tools: Batch script, sed for Windows Requirements: In folder C:\Folder_With_VMXfiles Need to replace some text inside the ...
4
votes
3answers
3k views

How to get AD user's “Display name” instead of logon name (domain\userid) while exporting “send as” and “full” permissions?

I have googled and created two scripts . (1), (2) (1)First one is to export "Full Access" of a shared email box called "ap.cz" Get-Mailbox ap.cz | Get-MailboxPermission | where {$_.user.tostring() -...
2
votes
2answers
55 views

Finding script trying send spam via postfix

I have had this problem before with crap wordpress sites on my server but it was always easy to find the source, a php script by looking at the spam header and see the php scripts name. But this time ...
1
vote
2answers
35 views

Launch AD for alt domain batch stopped working after win10 upgrade

I have a simple batch script that I have been using to launch the AD Users and Computers modules for domains other than the one my current session is logged in to. I've been using this for longer ...
8
votes
1answer
286 views

Entering local admin username and password in a script

I have alot of clients on my network and I want my script to do the following: [1] Open an elevated command prompt using the local admin details. Note: I do not want to have to enter a username ...
0
votes
1answer
120 views

Backup powershell script pauses until i press space

I made a script to export all mailboxes ( as secondary backup for my Exchange 2013 Server.) The script basically gets all the mailboxes from a list in a text file and does a for-loop going through ...
-1
votes
2answers
1k views

Powershell script to export email address of users in an OU

so I have a ton of OU's on our DC that are all formatted the same way with a 6 digit number to start and then a name after the number. I am wondering if there is a way to write a Powershell script ...
0
votes
2answers
81 views

Don't work correctly script in bash

I need to get interface by number. My script: #!/bin/bash interfaces=/root/tt interfaces_with_numbers=/root/tt2 ls -1 /sys/class/net > /root/tt cat -n $interfaces > $interfaces_with_numbers ...
1
vote
1answer
79 views

Don't work loop on bash

I have written script on bash. It got all list of interfaces. And in loop has compared with variable. But it doesn't work good. My script: #!/bin/bash search=`ls -1 /sys/class/net | grep -v lo` echo ...
1
vote
2answers
1k views

Script to delete FTP data older than 7 days

Currently I am using following simple line script to take backup of server directory to remote FTP location # Take backup to remote location ncftpput -z -R -uusername -ppassword ftp.example.org /...
1
vote
2answers
124 views

Exchange 2013 script to copy email from a users inbox for a specific date range?

Client Mailbox Exchange 2013 Microsoft Scripting Looking for a script that will accomplish the following task. Copy all email from a user’s mailbox that meets a specific date. The copy script should ...
-1
votes
2answers
1k views

bash script to detect when a file is added to folder and command exec

I am trying to write a script to detect whenever a file is added to a specific folder and run a command using the last file added name. What I am specifically trying to do is to create a QR code for ...
1
vote
1answer
55 views

Running script on instance that is created from AWS snapshot

I've a AMI that I'd like to launch more instances based on this. But seems when I create instance based on this images, it doesn't boot-up. So the scripts that I would like to run on startup doesn't ...
1
vote
2answers
706 views

Execute script when new email arrives (Postfix / Dovecot)

I want to execute a backup script (.sh) when I receive a new mail on my mailserver (running on Debian with Postfix / Dovecot). I've found many posts on this topic, but no one give me a working ...
2
votes
2answers
1k views

Changing root password via script fails but reports success

I have a project which requires me to make a script / sequence of commands to change the root password on a CentOS 7 installation. I can assume the user that will be executing the script is already ...
1
vote
0answers
2k views

whoami /priv for another user

Is there a way to see the privileges for any (local or domain) user in Windows ? whoami /priv works for the current user. Not clear from the docs: https://technet.microsoft.com/en-us/library/cc771299(...
0
votes
2answers
6k views

How to use sed to replace text with special characters

I currently have a script that generates random words to create passwords. I run this by selecting the script and letting it know how many words I want .e.g ./generate_passwords.sh 5. This creates ...
0
votes
1answer
81 views

Powershell: a simple script to take a list of commands and append the same cmdlet every time [closed]

I have a list of commands I run in a script like this Some-Cmdlet -someswitch | Outfile -filepath .\somefile.txt -append Another-Cmdlet -someswitch | Out-File -filepath .\somefile.txt -append Hello-...
2
votes
1answer
916 views

powershell: how to print command to file?

I'm currently using the Out-File cmdlet, like so: PS> Some-Cmdlet -someswitch | Out-File -filepath .\somefile.txt It works great. Is there anyway that I can actually get the command line itself ...
2
votes
1answer
995 views

How to use wget in an Expect script?

I first download a file to /root/TRY1/: #!/usr/bin/expect cd /root/TRY1/ exec wget --http-user $user --http-password $password $url Then I want to extract the file: cd /root/TRY1/ exec bash -c "tar ...
0
votes
2answers
166 views

Pure Perl RPM Version checker

I have a machine located in a secure environment that does not have access to the internet. I has a base load of CentOS with a handful of additional RPMs. This includes a basic install of PERL with ...
0
votes
1answer
597 views

Using Powershell to set SMTP port on an existing IIS 6 SMTP Server - Windows Server 2012 R2

Background I have a requirement to restore a snapshot of a server daily into a testing environment, once restored, it is necessary to update numerous bits of configuration to make it a test ...
0
votes
2answers
2k views

Store PS command output to variable and Invoke-Command

I need to store command output to pass it as variable in function later #This works [scriptblock]$command = {Get-EventLog system -newest 1 | Format-List} $command.Invoke() But when I try to Write-...
0
votes
0answers
63 views

Export Windows Registry for Services

I have a process that I want to automate, I have tried doing some digging but I can't find a way to do it, as I am not a heavy scripter. Here it goes: I want to have a script of some sort, that will ...