Questions tagged [shell-scripting]

Programming in an Interpreted language executed by a running Shell

Generic programming in an Interpreted language (as opposed to compiled) executed by a running Shell. Sometimes referred to as "Glue Code" due to the practice of managing the execution and output of one or more compiled binaries and passing said output to another series of commands.

621 questions
1
vote
0 answers

Powershell-Script is not exectued correctly

I have a power-shell-script which is called by a batch-file. The batch calls the script after it has set the execution policy to unrestricted. Currently the script does nothing more than writing a log-file, logging that it has been executed. Now the…
1
vote
1 answer

Mysql optimize one table in all databases

I see in the mysqlcheck manual that there's an option for --tables that overrides that databases option, but it isn't well explained. I'm trying to run mysqlcheck -o and I want it to optimize a specific table that exists in every database, but only…
1
vote
2 answers

Bash function hangs while command run perfectly without function

Following function hangs : ssh() { local RESULTS; RESULTS=$(ssh $USERNAME@$SERVER $SSH_COMMAND1); echo $RESULTS; } ssh; while if i run following commands they work fine : RESULTS=$(ssh $USERNAME@$SERVER $SSH_COMMAND1); echo…
Amber
  • 121
  • 5
1
vote
4 answers

Cannot get Exchange PowerShell script to run under Scheduled Tasks

I have a PowerShell script that works when entered directly into the PowerShell. The PowerShell program is run with the shorcut: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange…
1
vote
2 answers

Wrangling sed to find and reformat login date (or, how to kill idle mosh-server processes)

I have an old method of killing idle mosh-server processes, which doesn't work on my new VPS. Here's the old method, which I run in root's crontab to clean up mosh processes that have been idle for 10+ days: for tty in `w -sf | grep -P '\d\ddays…
1
vote
3 answers

Global Redirection of port 80 to 443

I'd like to setup my linux box so that anything hitting port 80 would simply be told ask that of 443. I want it to be regardless of domain, IP or whatever specific details may exist. If it can be requested of port 80, it should be told nope. We do…
flickerfly
  • 2,753
  • 3
  • 25
  • 27
1
vote
3 answers

How to start Rails from a shell script on Debian?

I don't really have any need to mess with passenger or capistrano at the moment. I simply want to run rails on boot on port 3000. I've attempted to replicate this tutorial for node as much as I could to run rails: I've a railsup script in…
dsp_099
  • 43
  • 1
  • 1
  • 8
1
vote
2 answers

Script to change MySQL password from command line

I host some websites for people with a simple server. I can't afford nifty things like cpanel, and I don't want to waste memory on a giant blob of perl like webmin. I am wondering if anyone has come up with a script so my users can change their…
John Tate
  • 179
  • 4
  • 19
1
vote
2 answers

How can I make ssh wait until the command exits?

I have a script that looks like this: SERVER="RHT372 RHTl373 RHT374 RHTl375" case $1 in "stop") for SERVER in $SERVER do echo "================================================" echo Stopping $SERVER ssh root@$SERVER…
user192506
  • 23
  • 1
  • 1
  • 4
1
vote
1 answer

Providing network drive access to a windows service

I have a windows service, which requires access to a network drive. As Windows Service does not perform interactive logon, it's not possible to use mapped drive from active directory user logon script. Which would be the best - secure and elegant…
1
vote
2 answers

Adding sleep / delay between iptables blocks in shell script

On one server, we're trying to block any access for the country China. We wish to implement this with iptables rather than via .htaccess. The problem we're experiencing though, is that when adding multiple iptables at once (and we're talking over…
zigojacko
  • 1,453
  • 2
  • 12
  • 25
1
vote
0 answers

Obtain the free_memory value in xen

I would like to know if there's an alternative to the command I am currently using to get the real free memory for the system (meaning memory that can be assigned to new domU) xm info | grep free_memory I have a script that reads several parameters…
aseques
  • 718
  • 4
  • 12
  • 28
1
vote
2 answers

Try the command multiple times

I need to execute a command and also check if it was successful. If there was an error, I should try again and the following code is working as expected. But what if I need to try the same command 3 or 4 times till it gets successfully executed? The…
shantanuo
  • 3,579
  • 8
  • 49
  • 66
1
vote
1 answer

Cronjobs putting archive in wrong directory

I am running a website on an Amazon ec2 instance running the default Debian linux. I set up a cronjob to copy the site files, take a database imprint, and zip them up. I want to keep the file archives in the same directory as the bash script…
Nicholas Finch
  • 275
  • 3
  • 7
1
vote
2 answers

Shell script :: Reading a column from file & store it in array

I am working on shell script where i want to store O/P of the command in array. I have a file containing rows & columns from where i want to extract 3rd column & store all values in a array. if suppose i have below in my file info.txt abc xyz …
Shailesh Sutar
  • 1,517
  • 5
  • 23
  • 41