Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [scripting]

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

-1
votes
1answer
20 views

Command that returns exit code still returning 0 when using “command 2>&1 | tee -a /var/log/file.log”

I'm running a script that executes a command and save the output to a file in /var/log. After that, it gets the exit code and execute another command based on an if/else condition. The problem is: 2>&...
1
vote
0answers
17 views

Allow standard user to modify HKCU registry from script

I'm writing a batch script to launch a program for my Citrix environment and I'm running into some issues with a couple of reg keys I'm trying to set in the script. essentially I'm launching an ...
0
votes
1answer
54 views

How to execute 2 scripts on a server via ssh by chaining them and within only a single connection? [closed]

I have these 2 commands that I send to my server: - cat ./script1.sh var1 var2 | ssh my_user@my_server.com - cat ./script2.sh var3 var4 | ssh my_user@my_server.com This is a part of Gitlab CI, but ...
-2
votes
2answers
51 views

“kill -9 …” throws a warning when it's run from a script [closed]

In my script I have this: #!/bin/bash kill -9 $(ps aux | grep '[m]y_app' | awk '{print $2}') sleep 3 ENV_VAR=val123 nohup my_app & Why does it print this: kill: usage: kill [-s sigspec | -n ...
0
votes
0answers
83 views

Mapping Network Drive w/Credentials using Logon Script - Asks for Password

G'day - due to some changes in our network architecture, I've been having issues mapping our users to a network drive/folder located outside of our AD Domain - eg, it is still within our network but ...
-2
votes
3answers
54 views

SSH to server as one user, switch to root and create mysql dump - how to script this

I want to be able to copy a mysqdump from a remote server to my local machine. I had a script to do this, but our operations guys have now changed the server permissions and it doesn't work. So ...
0
votes
0answers
13 views

Python 3 Script delete old or unused IOS files

I am want to develop a Python 3 script that I can use to clean up old Cisco IOS image files (bin files). A major issue for me is there is more than one bin file. Secondly, I do not want to delete the ...
0
votes
2answers
129 views

Copy files to network drive with powershell script and task schedule

I have powershell script that is copying files from local drive to network mapped drive. Everything works fine when i run this script via powershell but when i run this script with task scheduler it ...
0
votes
0answers
38 views

How to use “sudo” for installing an app on gitlab.com for CI?

I have a project at gitlab. I'm setting up Continious Integration for it. I need to install sphinx search engine and it requires sudo. - http://sphinxsearch.com/files/sphinx-3.0.3-facc3fb-linux-amd64....
-1
votes
1answer
50 views

Run commands in fish from bash script?

I have a rather long bash script for setting up a server cluster. I'd like to start switching over to fish interpreter but I'd like to do it in steps. Can I keep my bash script as is and add the fish ...
3
votes
1answer
58 views

Do group policy shutdown scripts run before Windows Services shut down?

You can have a [shutdown] section in group policy which specifies some scripts to run during system shutdown. Do all these scripts run before Windows services start receiving 'Preshutdown' ...
0
votes
0answers
40 views

powershell - get from ad group user name and they group

in my AD I have security group "Citrix" and in this group I have added a lot of groups "Citrix 1", "Citrix 2", and more... in this group has add users. I need to get information with powershell users ...
0
votes
0answers
14 views

INotify: Treatment of bulk moves vs. individual files

Our environment is making use of inotify events for the purpose of triggering file transfers, but with our lab being a closed environment it is difficult to replicate inbound streaming file writes. ...
0
votes
1answer
35 views

List all Linux servers where my account was created

I'm a new Linux sys. admin (in the past, Windows sysadmin) We have 400 and more Linux servers. On some servers my account is create and on some not. I want to know wich server I have to ask for ...
0
votes
1answer
34 views

debian cron.hourly script not executing

New to cron on debian 9 , I have a file called ipupdate in /etc/cron.hourly/ipupdate -rwxr-xr-x 1 root root 132 Jul 11 18:21 ipupdate the file has a single curl command like this: curl "https://..."...
0
votes
2answers
356 views

CentOS 7 custom service failure (Interactive authentication required)

I am trying to setup an OFBiz fork called Scipio as a service on CentOS 7. The service wrapper script changes the user to a dedicated one for the program. All of the program's files are owned and in ...
1
vote
0answers
83 views

Set Windows 10 Default Start Layout

How can we set the default start layout and task bar icons for each user in Windows 10, yet still let users modify them later? I know you can use an XML file to set these, but a standard XML file ...
0
votes
1answer
1k views

how to open sftp connection and execute sftp commands in shell script?

I need to connect to multiple SFTP connections and copy files to my system. I will maintain one CSV file in our local system. It will have multiple partners' information of username, password, ...
0
votes
1answer
112 views

Powershell - piping in related variables from a list

I am trying to export formatted folder ACL permission list for a limited set of folders on a file server. I have a list of folders to read out permissions from and a list of file names that I want to ...
3
votes
2answers
112 views

How to run a script on a server 1 minute after a commit has been made?

Apart from creating a 2nd script which would check the time of the last commit and then run the main script and which would be too complex of a solution, is there a simpler one?
1
vote
0answers
42 views

ideas needed - cut the smb connection when disk full

Hello sometimes we are having issues like when some misbehaving user copies files to a server via admin share or other share and he causes disk drive to fill and a p1 ticket be created by monitoring. ...
0
votes
0answers
30 views

debian 9 script to add sudo user

I was trying to make a script to set up a sudo user . Copy pasting one by one Debian commands work , but not running in script . Debian9=$(lsb_release -a 2>/dev/null | grep '^Description' | awk '{...
0
votes
0answers
36 views

What are the Non-GPO settings like Fine-Grain Policy settings that affect AD objects in Windows AD environment

I would like to know the list of possible settings available in Windows AD environment (irrespective of version) that are Non-GPO settings which could be used to modify the configuration of an AD ...
-1
votes
3answers
735 views

Bash script: save last line output from terminal

I am writing a bash script in which I would like to save the output of the last command in to a variable before running my next one so I can display it later. I have tried a few different methods ...
2
votes
1answer
82 views

fdisk with a a single command fail in the second execution

I ran a script to format a disk with fdisk like this: (echo n; echo p; echo $number_part; echo $firs_sector; echo $second_sector; echo t; echo $format; echo p; echo w) | fdisk /dev/$disk when i ...
1
vote
0answers
97 views

remote powershell unrecognized command when calling functions

I have two servers. Server A needs to contact server B and run a specific function withing a powershell function library (just a .ps1 file) that I've created. The function that is being called also ...
0
votes
0answers
21 views

Making post alert script for snort

I`m trying to make a script that trigger an action if 5 snort rules ware broken in 24 hours interval. I`m putting all my snort logs in alert.log Can some one help me to make a script that motor this ...
0
votes
1answer
64 views

Appending deployment.properties to enable TLS

I need to be able to append everyone's deployment.properties file to add additional lines to enable all versions of TLS. Big enterprise uses multiple different versions of Java and also multiple ...
-2
votes
2answers
59 views

Check existence of multiple network shared files

Let's say I have a list of files (files.txt), which looks like: \\myshare\file1 \\myshare\file2 \\myshare\file3 How is it possible to check via a batch script (windows) to check if those files exist ...
0
votes
1answer
922 views

Appending to an array within a ForEach-Object loop

I've run into a strange problem when attempting to append to an array from within a ForEach-Object loop that is traversing another array. I have attempted to recreate the problem as concisely as I ...
1
vote
0answers
150 views

Set-Acl : Attempted to perform an unauthorized operation while using Addaudit Rule

I am trying to run Powershell script to set Audit Rule on C:\Windows\security folder on my Windows 2008 box. Below is the script: $FileDirList = ("C:\Windows\security") $AccountName = New-Object ...
1
vote
0answers
75 views

automate server downtime for different servers at different days and time

I have created script with Ansible and also with Python to put servers down in my work environment but If I can create group of all servers and set their downtime at once. Example: If I need to put ...
0
votes
0answers
92 views

how to delay LAN using batch script or cmd

I want to delay local area connetion (like clumsy tool) using batch script or command prompt. Basically I want to make network delay for my test purpose. I have no idea from where to start and how.
0
votes
0answers
17 views

auto update 1 vhd when another collects the updates

I have a server running server 2012, failed at making a shared vhdx. Instead I mounted the created vhd to another computer installed the games and programs I wanted. Unmounted the vhd and the copied ...
1
vote
0answers
45 views

Verified data retrieval from source with limited access

Briefly: I need to download data from a linux-based device, verify data integrity, and delete the source files (can't use rsync). Details: I have a hydrophone deployed at the bottom of the ocean as ...
-1
votes
1answer
54 views

Checking if a programm is running on linux

i'm trying to check if a program on a linux server is running and start it if not. But i get strange errors: #!/bin/sh SERVICE=nrpe ps -ef | grep -v grep | grep $SERVICE | wc -l if [ $? -gt 1 ] ...
1
vote
3answers
73 views

I want the bash script to echo only if I execute and not echo if executed by a cron job

I want to echo to the terminal if the script is being executed by me, in the flesh or I want to echo to a log file if it is being done via a cron job. Ubuntu 16.04 example: #!/bin/bash if [ ***** ]...
0
votes
1answer
57 views

How to monitor VMs and its resources under google cloud (GCP)

I have couple of VMs created on Google cloud platform and deployed tomcat based applications. Now, I would like to monitor the resources (like Memory , CPU, disk , applications etc). Is there any way ...
0
votes
0answers
57 views

Powershell Script returning unexpected value while attemting to automate software removal

I'm attempting to write a script that will be used to automate the removal of HP bloatware from the stock images on a fleet of HP laptops that we will be deploying for a client. So far I have: $...
0
votes
1answer
136 views

Script to delete many old user profiles from network share?

I have a network share on a Windows Server 2012 machine that is used to store all the user profile files (My Documents, Desktop, etc). There are hundreds of old users I need to get rid of and I am ...
0
votes
0answers
65 views

Simplify Bash IF statement when using set -e

I have many lines of code, like this: #!/bin/bash -eux set -o pipefail # do something else here with error checking and command logging set +e if ! dpkg -l htop | grep -qE '^ii'; then set -e ...
0
votes
0answers
31 views

Update win 10 remotely from .wim file? No server

I am looking for a way to remotely update (or reinstall) Windows 10 systems from a .wim file, and no I sadly I don't have access to SCCM or WDS... I did find Automate Windows 10 In-Place Upgrades ...
0
votes
2answers
604 views

How to su non-interactively?

I want to do something like this to non-interactively switch user: su otheruser -p <password> But this obviously doens't work... what will?
0
votes
2answers
140 views

Bash script shows error for “pwd”, simple script

I'm trying to make a Bash shell script but it is not working. Here is the contents of the script: #!/bin/bash pwd I would expect this to print out the current directory. Instaed, it prints this: ...
2
votes
2answers
28 views

Can different scripts share a lockfile to ensure they don't interfere with each other?

I've used flock a lot in the past to ensure that a process only spawns once (in case it gets hung up/etc) but I've never used it for two different processes. In this scenario two different scripts ...
0
votes
0answers
352 views

WSL command execution at startup/shutdown from Local Group Policy Editor in Windows 10

The base is a fresh install of Windows 10 with the Windows Subsystem for Linux (WSL) enabled and with a Ubuntu installed. The tool is "Local Group Policy Editor" under "Local Computer Policy > ...
0
votes
1answer
23 views

script to load balance webpages

Im new with shell scripting, and I need help, to create this scripts. I have 2 apache (active/standby) servers, and what I need is to have one script that will check the status of the server 1 (wget ...
0
votes
0answers
40 views

Centrally administering JInitiator settings

We have software in our network that relies on the JInitiator to function, and requires some custom settings within it: The cache directory needs setting. Cache size should be unlimited. A runtime ...
0
votes
1answer
119 views

Read all lines for .txt powershell

I have a PowerShell script that when I run it, create a local amdmistrator on the computers that I select and it gives me another txt in which they were created. But from the txt where the host ...
2
votes
1answer
2k views

Read file with parameters as parameter in powershell script

I have tried to do a powershell script the reads a file with parameters: File with parameters (params.ini): [domain] domain="google.com" [port] port="80" Powershell script that reads the file: Get-...