A shell script is a script written for the shell, or command line interpreter, of an operating system.
1
vote
1answer
387 views
How to format a curl command for a special task?
There is a search page in a form http://site.com/search.php and it sends a search query via POST request. I want to fetch this request via curl command line tool to inspect a POST request.
The HTML ...
1
vote
1answer
378 views
Running shell commands in .sh file results to error
I have two following linux shell commands:
echo 'CPU type and model'
cat /proc/cpuinfo | head -5 | tail -1
When i run these commands directly in Terminal, i get this result truly:
CPU type and ...
1
vote
1answer
1k views
Move huge number of files into date structured directory order
I have about 1 million files in this directory: /home/username/images/
Each of the files are called something like: 012345678910(Place)_0_20120414185957_28841.jpg with the timestamp part of the ...
1
vote
3answers
465 views
Execute a command on multiple hosts, but only print command if it is successful?
Here's what I want to do.
I want to check over 100 hosts and see if a file exists on that host. If the file does exist, then I want to print the hostname and the output of the command.
In this ...
1
vote
1answer
412 views
Alternative for `sleep seconds` that takes system load into account?
So I develop my server app and some client apps for it. After each rebuild I start my server (which tends to load qup all services for something like 2 seconds) and then I start my clients... So his ...
1
vote
2answers
521 views
The receiving of returns by Nagios from script through NRPE
I am using nagios3 and want to collect some information from nrpe_server.
Next script is at nrpe_server:
#!/bin/sh
#set -x
# script for checking disk usage on ZFS
# requires min zpool version 13 or ...
1
vote
3answers
660 views
Script to show number of files (by file type) in a directory?
I want to show this kind of statistics about a particular directory:
$ myscript.sh
.c 34265 files
.h 17866 files
.cbl 1804 files
.pco 389 files
[...]
Is there a tool that can do this?
Here is my ...
1
vote
2answers
261 views
Proper way to use shebang for bash
What is the recommended options in bash's shebang?
#!/bin/bash -e
I currently have it as above. This sources $HOME/.bashrc.
I don't want to source user's .bashrc/.profile as it might interfere ...
1
vote
1answer
236 views
Reading two files into an IFS while loop — Is there a way to get a zero diff result in this case?
I have a text file full of several hundred lines of sequences like this:
b 29.
b 52.
c 84.
c 83.
c 94.
c 93.
c 61.
b 38.
c 81.
c 92.
c 28.
c 37.
...
1
vote
1answer
645 views
Concatenate multiple strings with spaces in them?
I am trying to do the following in ksh shell:
JMX_ROOT=/bfs-build/build-info/mep_mainline-Linux.latest/core/mainline/automation
SMOKE_JMX_LOCATION="$JMX_ROOT/\"Smoke Set\"/*.txt $JMX_ROOT/\"Smoke ...
1
vote
1answer
126 views
Do we need to chmod a shell script before it can be rsh
I tried to rsh a shell script from OpenVms to a Red Hat linux. It seems that it is not executed.
I created the shell script in OpenVms and Ftp it to the linux. I then ls -la the folder in linux:
...
1
vote
1answer
92 views
XML parsing using xmllint and customizing the output
I have xml file (say input.xml) of the following schema:
<?xml version="1.0"?>
<TagA>
<TagB>
<File Folder="FOLDER1M\1" File="R1.txt" />
</TagB>
...
1
vote
1answer
121 views
How to create a password protected shell script [duplicate]
How can I create a password-protected shell script for read/write access. It should also be executable by all users without the password. I have sensitive information in the script.
1
vote
2answers
77 views
renaming a directory and its subdirs without affecting their files
I have to rename directories under the root directory with prefix "ms_PF" and then rename their subdirectories with the modified name of the main directory with an extra "_", and then copy all ...
1
vote
1answer
57 views
Automation of openldap installation
In my group we often install ldap on new servers. We have two different configurations currently. A mirrored configuration and just a regular standalone configuration.
The installation process gets ...
1
vote
1answer
72 views
Running a script as Grub boot option
I'm assembling some DR stuff for my Linux boxes. One item that would be really handy would be a GRUB option that would run a script to change my boxes from static IPs to dynamic.
I know we could do ...
1
vote
1answer
95 views
Cannot enter in centOS with any user
I am using cent OS Operating system without GNOME.
In the starting, it asks
localhost login:
Password:
It has one user named service under group name service whose password is also service.
I ...
1
vote
1answer
341 views
Reading the contents of the file and splitting using ksh
We're using a ksh script for installing one product.
I've another config file, I'd need to read this configuration file from my main script
Content of the Configuration file:
...
1
vote
1answer
187 views
Identify text/ascii files in Linux/Solaris
I have a little project to build bash script that search in the OS ( Linux/Solaris ) the current IP address from files and replace them with other IP address.
The problem is that IP address could be ...
1
vote
1answer
328 views
How to manage getops argument assignation
This is my first question.
I'm trying to make a small script with options and I'm using getopts to do it. The weird thing is:
The argument don't get assigned to the variable or it always enter the ...
1
vote
1answer
443 views
Regular expression how to get value in shell script?
I have to write a shell script to get value from a string .. something like that :
string="abcdef" pathName
How can I use "grep" command with the use of regular expression to get "pathName" ? Thank ...
1
vote
2answers
281 views
What scripting language or platform to use for web page downloads and screen interaction? [duplicate]
Possible Duplicate:
Does anybody here have experience in automating some tasks in web applications using curl?
Here is what I need to do? Wondering what platform is most suited - easy to ...
1
vote
1answer
263 views
Identify remote windows server from shell script
I need a way to Identify a windows SBS server, I have a script that mounts a file share on a SBS server, I need the script to positivity identify the server before mounting. It doesn't need to be ...
1
vote
2answers
382 views
To pass a parameter with sed
For my script I have to read the data from a file.
For example I have 2 files: one is a text file, the second is a csv file with 10 columns.
What I am trying to do is to read the csv and change the ...
1
vote
1answer
336 views
Power broker safe shell or full shell script
I am looking for a script which we can pass as an argument to the pbrun command.
Eg:
Login: test1
Passwd: xxxxxxx
Welcome to Solaris 10 gcmsys01
$ pbrun sysadmins safeksh
Here sysadmins is the ...
1
vote
2answers
709 views
Using rsync in a cronjob when a password is needed
Basically I have a bash script that fetches data from my server to perform a backup.
As it is now I have to start that script manually, enter the password, and then wait for it to finish.
I would ...
1
vote
3answers
153 views
ksh cannot cp from location with space in it?
I am trying to do the following in ksh but keep getting cannot stat message for the cp command:
JMX_ROOT=/bfs-build/build-info/mep_mainline-Linux.latest/core/mainline/automation
...
1
vote
1answer
644 views
How synchronize two disks (or folders) using symbolic (or hard) links (like rsync)?
I'm searching a tool or a shell script or another program to synchronize two or more folders or disks.
But it differs of rsync tool, because, I don't want to duplicate the missing file, but do a ...
1
vote
1answer
475 views
Allow www-data to execute a a script
I am trying to execute a script that will read a file written by PHP. The problem is that the script opens and some other files (C-ISAM file based database) and i have no clue what permisions to give ...
1
vote
2answers
2k views
Where should I put a script that needs to execute once when the user logs in graphically?
Using Gnome 3 on Fedora 15, where should I put a script that needs to execute once when the user logs in graphically?
1
vote
3answers
562 views
How do i execute a remote script with 'screens'?
I need to execute a script locally. The problem is, it needs to use screen and send the ctrl d command.
How would i do this? The script will be on my local windows machine. i can use winscp, putty, ...
1
vote
3answers
34 views
Solaris: Script for finding the physical device path of all installed fiber cards
I have a number of systems (with quite varying type, generation and architecture unfortunately).
I need to create a list of fiber cards on these varying systems.
I am able to use prtconf -v, and ...
1
vote
0answers
68 views
Using sshpass, return code (exit status) differs for reasons unknown using valid commands
There are a few things going on here but I think ultimately, either CLish or SSH is returning an exit code that is messing up my work flow.
I'm attempting to connect to a remote machine (CLish shell) ...
1
vote
0answers
74 views
how to create a script to backup MySQL databases on separate files?
I need to create a script so to automate the backup process for my database server. Today there are 19 databases on the server and to prevent some schema is created and not contemplated by the script, ...
1
vote
3answers
155 views
How to get data count between two strings with multiple occurences in the same file
I have the data in my file as
START-OF-FIELDS
ID
NAME
DEPT
END-OF-FIELDS
START-OF-DATA
1|joy|cs
2|sam|ec
END-OF-DATA
START-OF-FIELDS
ID
NAME
DOB
DEPT
ADDRESS
END-OF-FIELDS
START-OF-DATA
...
1
vote
0answers
102 views
rc.local not being executed when os boots up
I have a script that needs to be run when os boots up. I added it to /etc/rc.local. It was working fine for sometime but now rc.local does not load at boot time.
When i checked the permissions on the ...
1
vote
1answer
89 views
reading from a file and changing its pattern into an array?
I have a CSV file containging entries like this :
ipaddress,VLAN,VLANid
10.192.168.1,vlan-xyz,3
10.192.168.1,vlan-abc,8
10.192.168.1,vlan-mnp,11
10.192.163.24,vlan-llz,3
10.192.163.24,vlan-bbz,5
...
1
vote
1answer
256 views
Command/scripts to check the Reverse DNS Lookup time
I am working on a project in which one master communicates with numbers of slaves. For that it has to make connection with hosts in network. But sometimes it hangs.
I think that the reason behind is ...
1
vote
2answers
79 views
how obtain directory files info
I have the need to get information about a specific directory, basically I need to know the correlation between small, medium and big files.
I came up with this:
for i in K M G; do
printf $i
du ...
1
vote
2answers
146 views
Query list of servers for memory/cpu allocated
Running RHEL 6.2, trying to write a bash script to SSH to a list of remote servers, and write the CPUs and Total Memory to a file, one line per host in the following format:
HOSTNAME1 CPUS: 12 ...
1
vote
2answers
53 views
Reduce redundant logfile
I often have longer redundant log files, redundant in the sense that blocks of text repeat with minor changes. The length of the files makes it difficult to spot the actual information. I had the idea ...
1
vote
2answers
222 views
Total amount of memory usage by a single process say httpd
I want to get a full added amount of memory usage for a particular process. Here say I want to have the total amount of memory taken by httpd. So if I do a tail command as "tail -M"
I get
PID ...
1
vote
0answers
32 views
mapping Character keys
I really dont understand bash`s use of control characters. I understand simple things like adding colors with escape sequences but am at a loss for how to do things like bind keys in .inputrc
For ...
1
vote
1answer
180 views
connect to a remote server through ssh [duplicate]
Possible Duplicate:
How do I execute a remote shell script over SSH and be prompted for passwords by commands that require it in that script?
I want to connect to a remote server through ...
1
vote
0answers
68 views
How to make tcsh not insert whitespace in a command that spans multiple lines
Bash does not seem to insert whitespace but tcsh does.
Tcsh
bash-3.2.25$ tcsh -c 'echo $tcsh; echo A\
> B'
6.14.00
A B
Bash
bash-3.2.25$ bash -c 'echo A\
> B'
AB
How can I ask tcsh to not insert ...
1
vote
0answers
36 views
Redirect hard return to other terminal [duplicate]
Possible Duplicate:
Construct a command by putting a string into a tty
Suppose I've run a command in a terminal ( /dev/pts/1 )
and it starts to ask me for input ( "press y to confirm" )
and ...
1
vote
0answers
167 views
Can I get the backup option of cp and mv to work with directories?
--backup[=CONTROL]
make a backup of each existing destination file
The man page does say that it works on file. It doesn't seem to have any effect on directories. Is there anyway to make this ...
1
vote
1answer
331 views
Script that unpacks a initrd, allows editing of the preseed.cfg and the packs it to cpio and gzip again
I want to program a script that allows what is said in the title. So basically I gunzip the initrd, than unpack the cpio, open vi to allow editing, save, pack with cpio, and gzip again, so nothing ...
1
vote
2answers
760 views
regex find and replace 0x0D, 0x0A characters
I have a text file of a database dump with some line break characters (0x0A0x0D) in the middle of lines. I want to replace them with commas, but I can't do it simply, because those characters are the ...
1
vote
0answers
571 views
Which scripting language is most widespread in system administration tasks? [closed]
I am migrating to Linux and have some experience with the Mac OS X command line/bash. I'd like to automate system admin tasks via scripting, but I am unsure as which language is the most used in the ...
