Questions tagged [scripting]

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

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

Scripting is usually done in a scripting language. Such scripting languages are often dynamically typed and interpreted, as opposed to compiled languages. Examples of such languages include PowerShell, Perl and Bash.

1826 questions
8
votes
5 answers

How to remove a certain symbol for a bash script

I have a bash script where I get the disk usage, for example 60%. How can I remove the % symbol? Using grep or awk?
pmerino
  • 461
  • 2
  • 5
  • 11
8
votes
4 answers

Testing for a script that is waiting on stdin

Is there a way to determine if a script is waiting on stdin and cause the command to exit if detected? Here's an example, the command I'm executing takes a long time to run, but it will also prompt for input before starting w/o a prompt. I want to…
Noah Campbell
  • 619
  • 2
  • 9
  • 15
8
votes
3 answers

username and password for rsync in script

I'm creating a cron job to keep two dirs in sync. I'm using rsync. I'm running an rsync daemon. I read the manual and it says: RSYNC_PASSWORD Setting RSYNC_PASSWORD to the required password allows you to run authenticated…
d-_-b
  • 1,124
  • 3
  • 11
  • 23
7
votes
1 answer

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?
pregmatch
  • 303
  • 1
  • 5
  • 14
7
votes
1 answer

How do I remotely issue a CLI command to thousands of Windows domain computers at once?

I need to issue a CLI command (cmd.exe or PowerShell) to all of the thousands of computers on my domain. For obvious reasons, this is not going to involve doing the task manually, or physically visiting each machine. How should this be done?
HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
7
votes
2 answers

delete registry key using wildcards

I'm hoping to find a way to delete registry keys based on wildcards using a batch file rather than writing some vbscript. Does anyone have an example? I'm forced to proceed with MS's wonderful manual removal of Office as described…
netadmin_dude
7
votes
5 answers

Bash: mv directory one at a time

I am trying to move all subdirectories of a folder to another share on the same server. If I do a mv *, I will run out of space since the folders are not removed until all folders get transferred. So I'd like to create a short script that loops…
NinjaCat
  • 576
  • 1
  • 9
  • 21
7
votes
1 answer

Bash script parameters

I need to write a bash script, and would like it to parse unordered parameters of the format: scriptname --param1 --param2 --param3 Is there a simple way to accomplish this, or am I pretty much stuck with $1, $2,…
Brent
  • 22,857
  • 19
  • 70
  • 102
7
votes
1 answer

How to retrieve the current Windows NLA network location from command-line?

We have a Windows Server 2008 R2 domain controller which always sets its NLA location to 'Network 3' after a reboot. Without fail, this defaults to Public, which screws with my Domain profile firewall settings. I have to manually disable and…
7
votes
4 answers

How to check that all ZFS snapshots within a pool are without holds before destroying that pool

Question Already I can check each snapshot of a filesystem individually, manually. I would prefer to check all at once (all with a single command or script). Please: can that be done with a script? The answer should be good for file systems with…
Graham Perrin
  • 635
  • 2
  • 10
  • 24
7
votes
5 answers

Detecting upload success/failure in a scripted command-line SFTP session?

I am writing a BASH shell script to upload all the files in a directory to a remote server and then delete them. It'll run every few hours via a CRON job. My complete script is below. The basic problem is that the part that's supposed to figure…
Will Martin
  • 2,431
  • 5
  • 19
  • 18
7
votes
8 answers

how to write a script that only acts on new log entries

I feel like this should be a simple thing but I am having a hard time figuring it out. I am trying to write a script that will monitor one of the apache log files and take some specific action. But how should I go about monitoring the log…
karmet
  • 209
  • 1
  • 2
  • 14
7
votes
3 answers

How to safeguard a shell script against running out of control?

I've recently had an experience of writing a shell script which crashed a server (and damaged a partition) by consuming all resources. It was hooked up to a cron job, and it seems it took longer to run than the interval between executions, over time…
Steve Bennett
  • 5,750
  • 12
  • 47
  • 59
7
votes
4 answers

How to determine how many shells deep I might be?

I'm wondering whether I've called the shell recursively, is there an easy way to find out? Is any solution specific to the shell? I'm using bash.
cgp
  • 1,032
  • 3
  • 12
  • 15
7
votes
4 answers

bash script alert on error

I've a script which do. ls , cp, mv I want if any of the command fail this should alert over email as well as after successful competition. Any idea? I can adjust email alert but want to know how to check for errors and successful attempt.
User4283
  • 781
  • 3
  • 10
  • 27