Questions tagged as ['scripting']

A form of computer programming that — in the context of system administration — lends it self well to automating tasks.
Score: 1
Gilberto Martins avatar
weird behaviour in a Windows 2019 .BAT script
cn flag

I have to restore a backup from a Linux MariaDB to a Windows MariaDB, where the PowerBI gateway will import its data. "mariabackup" is MariaDB's physical backup tool. But to restore it, the destination folder (%programfiles%\MariaDB 10.3\data\) must be empty.

Since rmdir /S /Q "%programfiles%\MariaDB 10.3\data\ will remove the "data" directory (what I don't want!!!), I have been working to avoid this ...

Score: 1
Curl Command Send Asynchronous Request
sx flag

I using this curl request for sending data to API :

curl --location --request POST 'MY_IP' \
--header 'Content-Type: text/plain' \
--data-raw ' [{
    "event_id": "123",
}]    
'

I want to check the API performance by sending request asynchronously and measure the time take I tried to use xargs -P 10 which say send 10 request parallel but not able to do so ? Any help and how I can measure time ?

Score: 0
Is there a way to add a comment to a DHCP dynamic simple queue?
ng flag

I simply want to add a comment (specifically, add the host name) to the simple queues created by the DHCP rate limit option.

However, while scripting, when I tried the command

/queue simple set dhcp-ds<XX:XX:XX:XX:XX:XX> comment="hello"

I was met with the error

failure: cannot change dynamic

Is there another way?

Score: 0
Zareh Kasparian avatar
whats the diffrence between "command.sh > /dev/null 2>&1" vs "command.sh 2>&1 >/dev/null"
us flag

I have many shell and python scripts on my crontab that ending either with:

command.sh > /dev/null 2>&1

or

command.sh 2>&1 >/dev/null

I know that:

> is for redirect

/dev/null is a black hole where any data sent, will be discarded

2 is the file descriptor for Standard Error

> is for redirect

& is the symbol for file descriptor (without it, the following 1 would be c ...

Score: -1
Find file duplicates and convert them into links [WINDOWS]
gb flag

My users tend to save tons of duplicate files what consumes more and more space and generate HW and archiving cost.

Im thinking to create some scheduled job, to:

  1. find duplicate files (check file MD5 sum, not only filename / size)
  2. leave only 1 original file
  3. replace other redundant copies by link (shortcut) to file (point above)

Any idea how to archive that?

Script / tool / tips ?

EDIT 28.10.2021

Score: 0
Amir Alamani avatar
Alternative location to store tmp files on linux
in flag

So I have a python script that I compile with pyinstaller to a single file. at the time of running, by default, the script will unbundle the modules in /tmp/ also you can change the default TMPDIR at the time of compilation.

PROBLEM: As you might know, this is a common security practice that you mount /tmp/ or /var/tmp/ as a noexec. the problem is that my script can't execute the modules from /tmp ...

Score: 0
How can I mitigate the risks of intentionally allowing users to run code on a server, in a resource-efficient manner?
us flag

To summarize:

I want to run multiple servers on a host, for different groups of users, and allow them to add and modify functionality of the servers at runtime with some form of scripting. This is a 100% necessary feature for what I want to do, but there is obviously a lot of potential for this to go horribly wrong; what are some actions/approaches I can take to mitigate the risks involved?

It's pr ...

Score: 0
Configure NGINX to deliver different JSON content based on $http_referrer
cn flag

I am working on a service + webapp + mobile app combo where

  • the mobile app is used to consume content
  • created by an open community of authors on the web app
  • with the whole being serviced by a server running Nginx on Ubuntu (well some requests are proxied off to backend Nginx servers) but that is a detail

The issue that I want to deal with efficiently is the one arising from the fact that the conten ...

Score: 0
Tony Chong avatar
PowerShell: Why am I getting this error?
cn flag

I am trying to use the PowerShell Invoke command. I am using it correct but I don't know why I am getting an error.

Invoke-Command Get-EventLog –LogName Security –Newest 100 -ComputerName WIN-9F8JQL0989

The error message:

Error message

Score: 0
How to merge two data sources with slightly different folder names
cn flag

How can I copy all .msg files that are spread throughout some GUID sub-folders in one folder to another folder that has a slightly different folder name at the end. Is it possible?

So for example:

  • Source
  • c:\Folder A\16-1167 Contoso 1 Hacker Way\Correspondence
  • c:\Folder A\16-1168 Company name, address\Correspondence
  • Destination:
  • C:\Folder B\16-1167\0ba45cbd-6da8-4a4c-ae1c-9aca13aab1db\1\filename.m ...
Score: 0
Sidd avatar
Not able to access groovy variable inside shell script in JenkinsFile
cn flag
def NAMESPACE = "Dev"

def BODY= sh(
script:'''body=$(cat <<-EOF
{
    "name": "${NAMESPACE}",
    "type": "regularwebapp"
}
EOF
)
(echo $body)''',
returnStdout: true
).trim()

The above doesnt work, output is as follows:

{
    "name": "",
    "type": "regularwebapp"
}
Score: -2
Michael Altfield avatar
Programatically get full path to binary in powershell (which, where, Get-Command)
cn flag

How do I get the absolute path to a given binary and store it to a variable?

What is the equivalent to the following for Linux Bash in Windows Powershell?

user@disp985:~$ path=`which gpg`
user@disp985:~$ echo $path
/usr/bin/gpg
user@disp985:~$ 

user@disp985:~$ $path
gpg: keybox '/home/user/.gnupg/pubring.kbx' created
gpg: WARNING: no command supplied.  Trying to guess what you mean ...
gpg: Go ahead  ...
Score: 0
Mhd avatar
command that cannot work in background (asterisk)
ru flag
Mhd

am trying to run script in background which contain command such like "asterisk -rvd >> xyz.log", when I run it directly it work well but when run it with any background way (service, cron, &, nohub,,) it stop directly with this message: stopped

so what is the prober way to run this command at background ?

Score: 0
wrieedx avatar
Adding "Never saved" websites to Edge via Group Policy, Registry, Script, etc
cn flag

I would like to push "Never saved" websites to users' Chromium Edge settings. The goal is to disable password saving for these particular websites/domains.

The method doesn't matter, only the end result. In this way, solutions that use Group Policy, registry change, script, etc. are all okay if they work. (Of course, adding the settings manually is no good).

NOTE: I have searched the Group Policy se ...

Score: 0
gabb00 avatar
how to launch a script using an alert in gcp?
to flag

I want to generate an alert in Monitoring and Login and I want that when that alert is triggered, my script is executed (which I already have generated in my cloud repository), how could I do it?

Score: 0
Domain users last logon time on a specific (domain joined) computer
au flag

So I have all the once_logged_in profiles listed in C:\Users folder but I need to find out when was the last time these users logged in onto the same computer locally or remotely with their domain user credentials. Is their any easy way to reach this goal? I mean scripts in PS or batch commands, wmi, anything. Unfortunately event log auditing is not on.

Score: 0
Black4Killer avatar
I Have a problems with qoutes in my bash script
au flag

how to do so that in this script which searches for something from the database. he searched for it and changed its name in the terminal. I have a problem with the quotes here. Maybe anyone know how to fix it?

spr-ustawien()
{
echo -e "\e[31;43mSprawdzanie Ustawień\e[0m \e[101mIP $1\e[0m"
intertube=0
while [ $intertube -ne 1 ]; do
ping $1 -c 5
if [ $? -eq 0 ]; then
sshpass -p (pass) ssh -t (user)@ ...
Score: 0
How to setup a daily report of users which are sending more than a defined numer of email outside organization within 24h
in flag

I'm trying to create a script and schedule it on exchange in order to have a daily report for users which are sending more than a defined numer of email outside organization within 24h.

I found this similar script but it is not the same scenario as the one i'm trying. Also i'm using Exchange 2016:

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010

$output = Get-TransportServer | Get-Message ...
Score: 0
John Christopher Asajar avatar
How to select using script on Task Scheduler the "run with highest privileges"
ua flag

Hi I'm doing some scripting to add a task on a Task Scheduler. However I need to have a script to select the "run with highest privileges".

Sample code:

Dim settings
Set settings = taskDefinition.Settings
settings.Enabled = True
settings.StartWhenAvailable = True
settings.Hidden = False
Score: 0
Ror avatar
Restart services on multiple remote servers securely
om flag
Ror

I need to write a script so that my colleagues and myself can restart different services on multiple servers. We all connect to the servers with LDAP so i'd like my script to connect our LDAP users to the server and then use sudo to restart the services (I can write a script on each server to restart all the services needed). Right now the script simply run a command like

ssh -t user@host "sudo ser ...
Score: 1
wondaah avatar
Powershell Script setting WMI CIMV2 Permissions
nl flag

I am currently trying do change up a script so that I can put it into a GPO. The Script itself works but I want to do a "if else" around it.

The Script is found here: https://gist.github.com/exchange12rocks/950aa29f66e6369d2c02fa8583bb3a75

The goal was to check if a registry key exists and if not, create it and set it to 1. So that way the Script only ever runs once.

I did the if else like this:

Score: 0
Emersonjr avatar
Awk script to filter text output to single line
fr flag

I have a script that is giving me an output like this:

ruby-devel is needed by software1
tcl is needed by software 2
python3 is needed by software 3
ocaml is needed by software 1

I'm new to awk but was trying to script it to get the first word, and put it in a single line (can use sed or the best way to actually do this, I couldn't do it) to be able to build an output like this:

You need to get: ru ...

Score: 0
Script not running on startup for GPO
za flag

I have seen many posts on this website about something similar but none of them have had the resources to fix my issue so I will go into as much detail as I can. If I leave any information out let me know.

We have a server with an exe file on it to start an update for a software called Bluebeam. I wrote a script file to start that exe on startup and placed it in the same directory as the exe. Not ...

Score: 0
Capture and convert Windows Defender Firewall log to allow rules
cn flag

is there a way to capture the Windows firewall traffic (TCP/UDP, Ports, IPs) for some time and then convert them to allowed firewall rules on Windows systems?

It would make sense in my opinion to capture the traffic for like a week while "allow" both incoming and outgoing. Then let the main programs use their ports and capture the traffic into the Firewall log. Then create allow rules from the lo ...