Questions tagged [scripting]
A form of computer programming that — in the context of system administration — lends it self well to automating tasks.
1,835
questions
0
votes
0
answers
19
views
Script run from crontab doesn't work [duplicate]
Running on the server I have a command that is started at boot as a service and it works well, now if I run the command that gives me information on the status of the service I get the data view, if I ...
2
votes
2
answers
7k
views
Printing a '$' (dollar sign) to a file
I want to echo/printf a dollar sign into a file - but echo $ > myfile or such does not work (not surprising).
I tried escaping it like echo \$ > myfile but it is also not working.
What is the ...
3
votes
5
answers
5k
views
Search and delete lines matching a pattern along with comments in previous line if any
I have a requirement to write a shell script in csh to search and delete lines matching a pattern along with comments in previous line if any. For example if my file has the following lines
Shell ...
0
votes
1
answer
51
views
Ubuntu/Orange Pi5 retrieve open tabs on Chromium (kiosk mode) via terminal - Powershell
I have a problem as of late where I am developing some PowerShell script to manage and update some digital displays. Please see below for my work in progress (By no means done).
I am struggling to be ...
0
votes
2
answers
8k
views
PowerShell script to report free disk space on servers
I am required to get reports about free disk space on our exchange servers.
I found this link : https://gallery.technet.microsoft.com/scriptcenter/PowerShell-Script-Sample-f7164554
But I am unable to ...
2
votes
1
answer
6k
views
Not able to access groovy variable inside shell script in JenkinsFile
def NAMESPACE = "Dev"
def BODY= sh(
script:'''body=$(cat <<-EOF
{
"name": "${NAMESPACE}",
"type": "regularwebapp"
}
EOF
)
(echo $body)''...
1
vote
1
answer
6k
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(...
2
votes
2
answers
6k
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 ...
0
votes
2
answers
4k
views
Check Windows registry to see if host is joined to an Azure AD domain?
On a Windows PC joined to a 'traditional' Active Directory domain, querying Win32_ComputerSystem or Win32_NTDomain returns the domain name.
On Azure anything [joined], those classes return nothing.
...
10
votes
2
answers
7k
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 ...
0
votes
1
answer
127
views
How to run a batch script completely and automatically on event such as sleep/hibernate and shutdown event using task scheduler?
I have written a batch script to perform some folder synchronizing task. I have scheduled the script to execute using task scheduler on events such as sleep/hibernate(kernel power event id 42) and ...
0
votes
1
answer
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 ...
-1
votes
2
answers
374
views
Run commands remotely via SSH with a powershell script natively
We want to run commands on our network devices via SSH from within a powershell script. I know that we can do:
ssh [email protected]
But this is interactive and requires you to accept ...
0
votes
3
answers
5k
views
Remotely initiate windows updates
I have a network with countless workstations on it and the windows updates are done through WSUS in push cycles to allow us to use a generic image and configuration and avoid network congestion.
I ...
19
votes
8
answers
54k
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]=...
14
votes
7
answers
34k
views
Bash script to retrieve name of Ethernet Network interface
In Ubuntu 16.04 I made a script to dinamically configure IP address of the wired ethernet interface based on certain parameters.
Now the problem is that in my script I assume that the name is eth0, ...
0
votes
1
answer
47
views
Custom Script-based Backups
I'm a believer in having multiple restore solutions in place for the environment I support.
I have a production backup solution for my Windows Server environment. It includes an agent on each box and ...
44
votes
4
answers
71k
views
How to output a list of changed files from rsync?
I am using rsync in a bash script to keep files in sync between a few servers and a NAS. One issue I have run into is trying to generate a list of the files that have changed from the during the rsync....
0
votes
1
answer
81
views
Can't get sub_filter to work in nginx, could it be an ownership/permissions issue?
I have http_sub_module installed, but the 'sub_filter' line is not working. I'm trying to use it for a dynamic nonce for CSP as per these instructions, replacing some text in script tags with the ...
0
votes
3
answers
263
views
Shell script capturing values from output of command
From a shell script, I run a ping command:
ping -c4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=58 time=34.2 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=58 ...
0
votes
0
answers
59
views
not able to send mail with attachment from linux ubuntu : 20.04 by using email mailutils (sendmail keyword)
code :
subject="Service resilience service status"
body="Service is down"
from="[email protected]"
to="[email protected]"
attachment="/home/ubuntu/...
1
vote
1
answer
125
views
not able to send mails from linux ubuntu : 20.04 by using email mailutils (sendmail or mail keyword)
code :
subject="mail subject"
body="Hello World"
from="[email protected]"
to="[email protected]"
echo -e "Subject:${subject}\n${body}" | sendmail -f "...
18
votes
8
answers
73k
views
PowerShell prompt to continue execution of code
I have a script I am using to automate WSUS processes, and the last stage of it goes on to remove all old/unnecessary files/objects.
I would like to prompt 'Press 'Enter' to continue with removal or ...
2
votes
2
answers
1k
views
fail2ban txt list creation of banned IP
using fail2ban for years, working nice, would like to automate and harden the security for my router.
So I would like that fail2ban created a local file, example, list.txt file with a list of banned ...
3
votes
2
answers
330
views
Vmware tags and Ansible , empty out in Ansible but VMs have tags
I am trying to filter out the list of VMs with specific tags. The sample playbook is as follows :
- hosts: localhost
gather_facts: false
become: false
vars:
vcenter_hostname: ...
6
votes
9
answers
64k
views
Ubuntu - dhcp server 'not configured to listen on any interfaces'
I'm at my wits end on this one; I have tried for hours to get this to work, but I'm stumped. Hope one of you can help. :-)
I'm trying to get dhcp3-server to work on Ubuntu. It's installed, and ...
0
votes
1
answer
48
views
command took very much longer to run from script than in CLI
In an AWS EC2 serverm, OS: amzn2-ami-kernel-5.10 x86_64
Trying to diagnose an issue of a slow running cron script, identified a single line of command that took more than an hour to run, everyday.
...
0
votes
1
answer
682
views
Script to cleanup Windows.old remotely
Problem:
A lot of older workstations on our networks are running out of hard disk space and I am looking for ways to stream-line the process of cleaning up some space. I understand I can use Disk ...
1
vote
5
answers
12k
views
Delete old windows print jobs
On our primary windows 2003 print server we share about 500 printers. We typically have about 50 stuck print jobs. Although far from the end of the world it bugs the hell out of me and I tend to end ...
0
votes
0
answers
213
views
I need to only get all active users in a Security Group, i can list all users but i get both active and inactive users
Need help to correct the scipt. The group FA-xxx-yyy-zzz has loads of users and undergroups in it.
This what i figured out so far is:
Get-ADGroupMember -Identity "FA-xxx-yyy-zzz" -Recursive |...
0
votes
0
answers
294
views
Systemd service executing a script with error handling
I have the following issue:
I created a systemd service which executes a script. This script contains several commands including psql commands which queries a database and stores the outcome into ...
0
votes
2
answers
2k
views
Script to delete many old user profiles from file server?
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
1
answer
92
views
Bash script : Print all lines between two pattern in variables with slashes
I have a directory that looks like so :
/path/to/files/data-file.1
/path/to/files/data-file.2
/path/to/files/data-file.3
/path/to/files/data-file.4
/path/to/files/data-file.5
/path/to/files/data-file....
1
vote
2
answers
1k
views
winget not working unless I do
When I open Powershell, and type winget - this is the response:
winget : The term 'winget' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of ...
0
votes
2
answers
1k
views
Download with Wget only if new version
Good morning,
I have a custom software that updates with a custom script.sh.
Part of the file goes something like this:
if [[ $software == A ]]
then
echo "downloading package..."
...
0
votes
0
answers
106
views
Windows Server - create firewall rules from network trace?
A good basis for firewall rules would be Zero Trust - only allow what is needed.
But in many cases, you do not know all the needed rules for a server connection. As a result in many evironments, the ...
1
vote
0
answers
232
views
mikrotik script is not run through GUI or Schedule
I get a problem that i have a one line script as bellow:
/tool fetch url="https://......"
When i run this script in winbox with "Run Script" button it does not work and after i ...
0
votes
1
answer
54
views
Secure method for automated copying of files over a root ssh connection
I currently have a few different services running on my home server and for simplicity, I have a single VM manage the certificates via certbot and just copy them across the network using SCP.
The ssh ...
6
votes
4
answers
3k
views
Can I create and manipulate unix "screens" in a script?
I have a work environment on my Ubuntu laptop in which I want to use three different screens.
Eg. in terminal, I usually write
screen -S mywork
run_server_1
then, ctrl-a c to create a second ...
-1
votes
1
answer
38
views
Extract Pages from Various PDF Files into New PDF File [closed]
From
a.pdf, I would like pages 2 and 5
b.pdf, pages 3 and 4
c.pdf, pages 7, 8, and 9
copied into a new PDF file.
All input pdf files are ten pages long.
I'm using bash, and plan to make many ...
24
votes
4
answers
58k
views
How to automatically and temporarily block an IP address making too many hits on the server in a short timespan?
One of my LAMP servers was recently brought down by some kind of script bot looking for exploits. From the looks of it, it was making so many requests a second, that it overloaded the RAM on the ...
1014
votes
15
answers
1.4m
views
How to determine if a bash variable is empty?
What is the best way to determine if a variable in bash is empty ("")?
I have heard that it is recommended that I do if [ "x$variable" = "x" ]
Is that the correct way? (there must be something more ...
1
vote
1
answer
487
views
Stumped on why my Startup GPO Script isn't executing BCDEdit correctly
Environment: MS Server 2019 DC, Windows 10 Workstations joined to the Domain.
The goal here is to set the Data Execution Prevention on a bunch of machines to OptOut. The way to do this via a command ...
0
votes
1
answer
55
views
Program started with Task Scheduler could not open my Printer
I have a C# program that executes some commands that generates a pdf and print it to a printer. The printer is hosted in a print server, so the way I accessed the printer is through my app config. (\...
0
votes
0
answers
92
views
Script to filter nginx logs to automatically running nftables
I have a domain served by nginx. nginx logs have this format:
178.128.120.151 - - [19/Jul/2023:20:27:25 +0200] "GET /favicon.ico HTTP/1.1" 301 162 "-" "Mozilla/5.0 (Windows NT ...
14
votes
4
answers
36k
views
Is it possible to change BIOS settings from Linux?
I'm trying to write a script to enable IPMI on a ton of machines without having to hook up a KVM to them one by one. Is it possible to change the BIOS settings from Linux? OS is SL6.
I understand ...
3
votes
1
answer
8k
views
Postfix: Pass a copy of an email to a script but deliver the original one to mailbox
It's actually quite simple: I want to pass all incoming emails to a PHP-script, but only as a copy, the original email shall still be delivered to the mailbox as usual.
I just can't seem to get it ...
-1
votes
1
answer
433
views
Backup of organization's GitHub repository
Is there any guides/best practices/manuals describing how to organize periodical backup (and of course restore if needed) of entire organization's GitHub, preferably with metadata?
1
vote
1
answer
12k
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 ...
0
votes
0
answers
17
views
Managing ougoing RDP sessions (MSTSC)
I am trying to automate a process where a user can establish an ssh tunnel in WSL then use that tunnel for an RDP connection using MSTSC. The same script might launch multiple instances of MSTSC using ...