Questions tagged [scripting]
A form of computer programming that — in the context of system administration — lends it self well to automating tasks.
1,836
questions
-1
votes
1
answer
449
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
18
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 ...
20
votes
5
answers
100k
views
What version of Windows Management Framework is installed?
How do you check to see what version of Windows Management Framework (WMF) is installed? It seems like it should be a simple thing to find out, but I cannot. Even Googling a bunch of different ...
0
votes
1
answer
2k
views
expect usage in bash script or bash command in expect script
I have a script below that works except for the expect portion:
#!/bin/bash
#
invdir=/home/john/inventory
for file in $invdir/$1
do
if [ -z $1 ] || [ -z $2 ]
then
echo "You must enter a ...
0
votes
1
answer
226
views
Run custom s6 script in docker container once only
I'm using automation (ansible) to deploy a dockerised app (gitea). The app runs s6 in its docker entrypoint.
I want to run my own script:
after the container's first load (so the files and db are ...
31
votes
12
answers
116k
views
How to find the gateway IP address in Linux
What command can you use to find the Gateway IP Address (ie. home router address) for eth0 in Linux?
I need to get the IP address from a command line app to use in a shell script.
0
votes
1
answer
992
views
systemd not able to run some bash scripts
(Update with more info May 16, see end of post for journalctl messages)
I've created a systemd timer and service with the purpose of running a handful of bash scripts. In particular I'm aimed at ...
0
votes
0
answers
223
views
Wireguard-ui: `Bad PATH_INFO : /login`
I've successfully installed Wireguard + UI to a Debian11 VPS with this AIO script.
But if I open the http://localhost:5000 via Webmin tunneling, I get this error:
Bad PATH_INFO : /login
How do I fix ...
7
votes
1
answer
19k
views
What is difference between */5 and 5 for minute value in crontabs?
I have cron with following definition.
*/5 * * * * /somescript
What is the difference between them? Is second one running every 5 minutes and first is running 5 minutes after every hour?
0
votes
1
answer
60
views
time nohup ./script --> the time hasn't been logged [closed]
I need to measure the time that Firefox takes to build itself from the source code. Here's what I do normaly:
nohup ./mach build > my_log.log &
I then prepended time to it:
time nohup ./mach ...
3
votes
3
answers
2k
views
How to script a check that the key in known_hosts file is correct
I would like to implement a function in a script that checks if the key that corresponds to a given host in known_hosts file is correct. The obvious way to do this is to attempt an ssh connection and ...
2
votes
2
answers
450
views
make ssh remember host's username
I connect to many servers daily.
my ssh config default username is "admin"
but servers comes from different environnements and username can changes. sometimes it will be "ec2-user" ...
2
votes
4
answers
4k
views
Equivalent of forfiles.exe in Linux
sorry if this is asked before but, I was curious about what is the equivalent Linux command of forfiles.exe in Windows? This came to my mind when I saw this question
1
vote
2
answers
875
views
Windows Equivalent to `sha256sum -c` (cryptographic hash, digest file, recursive integrity check, SHA256SUMS)
What is the equivalent to sha256sum -c in Windows?
I have a set of very important files that I need to copy-to and mirror across many different types of disks in many geographically distinct locations....
0
votes
2
answers
5k
views
How to run a python script in a specific directory automatically?
I have a python script that I wish to run at 5pm every Friday.
How can I achieve that ?
I understand I could do this through cron. However, as I have used relative file paths in the Python script and ...
1
vote
1
answer
33
views
What is the fastest method of getting a small amount of data from whitelisted servers?
I have a bunch of servers which build various different programs for various different systems.
Once a build has completed, it gets archived into a single file and compressed, then an md5sum is ...
3
votes
2
answers
7k
views
How do I redirect output to a single line in Bash?
Let's say we run two programs in the Linux shell, on one line, like this:
who -r; date
What should I add to obtain one line output?
0
votes
0
answers
49
views
Script to scan log file
I have a log file with the content below. Let's call it as cpu_usage.out:
2023-04-12 12:04: CPU STATISTICS CRITICAL : USED:- 2.52% IDLE:- 97.49%|CpuUsed=2.52;0;1 CpuIdle=97.49;0;1
2023-04-12 12:05: ...
11
votes
4
answers
32k
views
How can I use openssl to get results from HTTP GET requests?
I need to use openssl to perform some HTTP GET requests in a shell script. The line I'm using to do this right now is shown below. This is parsing the content of an XML response of the following ...
0
votes
1
answer
60
views
Is posible to write script that checks for differences between two patterns in configuration files
Linux. I have for example two config files.
First:
criticalexceptions => [
'yum-updatesd-helper: error',
'cups: cupsd shutdown succeeded',
'hda: drive_cmd: error',
'end_request: ...
0
votes
2
answers
4k
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 ...
0
votes
1
answer
721
views
How to run a script in a OpenVPN server hosted in pfSense when client connects?
I've got an pfSense 2.6 instance which hosts OpenVPN for clients. I'm testing with client version OpenVPN Connect 3.3.7 (2979).
There are some web endpoints with a dynamic IP addresses, so I can't ...
25
votes
4
answers
203k
views
How to edit Local Group Policy with a 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 ...
26
votes
5
answers
16k
views
Send bash -x output to logfile without interrupting standard output
Is there a way to send the information displayed by running a bash script with the -x option to a file, while not changing the standard output seen by a user running the script?
This is a debugging ...
1
vote
2
answers
1k
views
NGINX crashed and weird logs on access.log
When I came back home just now, I was checking my webserver if it was still running and I noticed that my NGINX server was not running anymore.
I tried to restart my NGINX a few times by running the ...
0
votes
1
answer
235
views
How to execute a local script from a local client with Ubuntu on a remote VPS with Ubuntu without prompt?
I have made extensive research about how to setup and secure correctly our new VPS with a Ubuntu 22.04 OS for three weeks, and I have currently a good idea of what has to be done.
However, I would ...
29
votes
10
answers
11k
views
Sort a list of domain names (FQDNs) starting from tld and working left
I am looking to sort a list of domain names (a web filter whitelist) starting from the TLD and working upwards. I am looking any *nix or windows tools that can do this easily, though a script would ...
0
votes
1
answer
759
views
Can forfiles search multiple drives in the same command and create a txt file of results?
Can forfiles search multiple drives in the same command and create a text file of results? I have the following that works to show me the results in command prompt but what I really need is a .txt ...
2
votes
2
answers
3k
views
What is the correct way to limit windows event log size?
I'm looking for a the best way to limit the windows event log size using PowerShell or a command line script. I want to run this script during installation of my application to increase the limit of a ...
2
votes
2
answers
928
views
Rsync include-from, exclude-from without source directory
I am working on a backup script but got some problems with my script, can you help me?
INCLUDE="/data/scripts/include.txt"
EXCLUDE="/data/scripts/exclude.txt"
DST="/backupdir"
rsync \
--...
1
vote
1
answer
669
views
SSH config: How to automatically execute an interactive script locally before connection?
Background:
I have a local script that needs to execute locally as a pre-requisite to making an ssh connection.
The script is already working, but currently users need to run the script, then make an ...
0
votes
1
answer
94
views
Fswatch observing folder for new files error from the example doc
I am trying to "listen in" on changes in a particular folder, then once a file comes in, I want to copy the file to another folder. I figured fswatch would be a great choice for this.
And as ...
-1
votes
2
answers
471
views
how can I detect if g++ compiled without errors
I have a script file to automatically compile a C++ program, then automatically run the executable.
script
g++ -o bin/program main.cpp
bin/program
The problem is, sometimes the compiler encounters ...
0
votes
1
answer
1k
views
Is there a scripting IDE of choice for VBscript / powershell?
We can't really do our job correctly without scripting, and sometime these scripts can be difficult to create / debug with only text editors
I'm currently using UltraEdit or Notepad++ as text editors ...
1
vote
1
answer
41
views
Scripted Password Change Does Not Survive Reboot Unless One Login Occurs - Debian 11
I am trying to automatically set the root password to random characters via bash script. The script is part of a Vagrant shell provisioner. If the script runs the password change only, I am able to ...
1
vote
1
answer
97
views
htaccess syntax issue when moving script to a subfolder
I have recently purchased a script but this script only works in public_html folder . I need to install it in a subfolder named shop ( public_html/shop/ ) . Now the following .htaccess rules work ...
0
votes
1
answer
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 ...
1
vote
1
answer
658
views
Divide one .pem file containing several certificates to several new .pem files
I am currently trying to figure out how I can divide one .pem file, containing several certificates to several new .pem files, but I do not know where to start...
The first .pem file looks like this:
-...
0
votes
1
answer
264
views
Alter Database recovery model & Shrink log, DB dynamically
I normally do on daily basis these operations in GUI
Alter database to simple recovery model
shrink log file
shrink database file
Alter database to full recovery model
I can understand script but ...
5
votes
3
answers
2k
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-...
1
vote
1
answer
4k
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
1
answer
644
views
Trying to start script but keep getting error syntax error near unexpected token `stop'
#!/bin/bash
#
case “$1” in
start)
echo -n “Starting Queue Manager”
/opt/mqm/bin/strmqm QMPROD1
sleep 10
echo -n “Started Queue Manager”
#
...
12
votes
5
answers
30k
views
Can the Linux ps command output be filtered by user AND command?
I need the pid for a process given its owner and its command. I can filter a process per user with "ps -u xxx" and its command by "ps -C yyy", but when I try "ps -u xxx -C yyy", they are combined ...
0
votes
1
answer
2k
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
1
answer
139
views
How to loop specific powershell script
I need to uninstall Java from several computers in my network. After almost all day of Googling it seems the best way to do this is with a Powershell script. I found one that I have tested on a few ...
1
vote
1
answer
449
views
Powershell Script to check free disk space on servers
I am in need to check free space on servers but I am getting more than enough details.
DeviceID : C:
DriveType : 3
ProviderName :
FreeSpace : 76691152896
Size : 160482455552
...
2
votes
0
answers
37
views
Disable computer on a schedule
I'm looking for a way to disable end user access to a Windows 10 workstation during a given period, say, from 8pm to 8am.
It doesn't need to be superuser-proof.
It doesn't need to be reboot-proof.
...
0
votes
0
answers
70
views
Need help to Split the below HTML text file in two parts using linux scripting
I have a html main.txt file, I need help to split it in two parts.
headpart.txt and bodypart.txt.
Below is my html main.txt text file - Original
<p class=\"auto-cursor-target\"><br /...
2
votes
3
answers
1k
views
How to change the display name of a bulk of shared mailboxes? accentuation issue
I have to rename a bulk of shared mailboxes to a new format, the script is ready and works but when the script runs, the names that contains accentuation are not being updated properly and a question ...