1
vote
2answers
65 views

How do I iterate bash arrays and make an SCP command efficiently?

I need to scp the files from machineB and machineC to machineA. I am running my below shell script from machineA. I have setup the ssh keys properly. If the files are not there in machineB, then it ...
1
vote
1answer
30 views

cp/rsync command with destination as symlink to a directory

I am working on a cPanel backup solution at the moment. We are now informed about this exploit. Exploit : Full ROOT ACCESS to server 1.) create malicious file from, normal user account: mkdir root ...
1
vote
2answers
62 views

Long string insertion with sed

I am trying to use this expression to insert the contents of one text file into another after a give string. This is a simple bash script: TEXT=`cat file1.txt` sed -i "/teststring/a \ ...
-1
votes
2answers
100 views

how I can get the value of JAVA_HOME from my client

I have nagios client and server, how I can get the value of JAVA_HOME from my client? I have use to set shell command in script that is running from remote host: echo $JAVA_HOME and printenv | grep ...
0
votes
1answer
33 views

Is there a tool for indexing a directory in order to perform cheap content search? (hashing by word, for example)

I am often using grep -R on an entire directory tree to find all files that contains a specified word. I wonder if there is a tool that makes the whole operation much faster, maybe via hashing? (Unix ...
1
vote
2answers
261 views

Shell script command output in if condition comparison fails to compare to same value string

I'm incorporating a script snippet which determines Android version via: adb shell getprop ro.build.version.release which returns: 4.1.2 or 4.0.4 The snippet currently looks like this: if [ "$(adb ...
2
votes
3answers
146 views

how to convert a running process into a nohup and keep a logfile

I have a process currently occupying a terminal ]$ command some_argument I want to exit from the terminal and go home, but in the mean time I don't want to kill this running process. For the ...
1
vote
2answers
64 views

If I know the PID number of a process can I know its name?

If I have the PID number for a process (on a UNIX machine), how can I know the name of its associated process? What do I have to do?
-1
votes
2answers
264 views

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

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. ...
1
vote
1answer
733 views

Linux- Permission denied?

I'm installing Neo4j server as a linux service, but when I install it, I get the following message: /sbin/insserv: Permission denied What is this? What should I do? I'm running everything with ...
1
vote
1answer
53 views

bash_history file and history command showing different entries

I am using the Terminal app on OS X to try and clear my command history. The entries within my $HOME/.bash_history file do not match what is returned by the history command. The echo $0 command tells ...
1
vote
2answers
159 views

Why need to use exec in upstart script?

I often see some upstart script has the to use exec, what is the point? Seems removing the exec the script also work? e.g. start on runlevel [2345] stop on runlevel [06] exec /path/to/program
0
votes
1answer
145 views

OSX terminal bash permission denied after GIT changed file permissions while cloning repo

I am a beginner at OSX/Unix command line. I have a GIT repository that was created on my OSX computer. Recently I cloned the repo and went to run a bash script within the repo via ./BashFile.sh. This ...
0
votes
2answers
142 views

Sync files between two computers connected to same network using rsync command [duplicate]

Possible Duplicate: Need help w/ rsync I have two computers connected to the same network, say Computer A and Computer B. Computer A has some backup files in a directory that needs to be ...
1
vote
4answers
69 views

Howto: command/tool ability check

When developing a shell script that should run on various unix/linux derivates, i sometimes have the problem that some tools have to be called in a different way compared to other systems. For example ...
0
votes
1answer
90 views

unix malicious scripts/ksh execution

I'm wondering whether my architecture poses a security risk. Details: The whole website is not ROOT owned but still, the APACHE user used instead has some pretty advanced permissions. I have a ...
0
votes
0answers
329 views

readlink: illegal option — f

Recently the script was working fine, but from some days I'm receiving such message, while running the readlink -f "$0" command: readlink: illegal option -- f usage: readlink [-n] [file ...] I was ...
1
vote
1answer
101 views

Error when using mv

I am receiving an error when trying to mv some files that really doesn't make sense. I receive this error: mv: cannot move `thatDir' to a subdirectory of itself, ...
1
vote
2answers
167 views

Different behaviour of script locally and over ssh

I have a script on a server-A Script-A #!/bin/bash -l echo "script-A.sh" | change-environment.sh When I ssh onto server-A and execute it, it works fine. However, when I ssh user@server-A ...
-2
votes
2answers
200 views

Bash combine multiple commands into a one liner [closed]

Is there a way to combine the following into a nifty "one liner": echo "free -m" > /tmp/dC4v2cK bash /tmp/dC4v2cK
2
votes
1answer
101 views

Unix Command to timestamp the output of a file, but with the relative-to-when-it-started time?

There are numerous programmes (e.g. ts in moreutils), and various bash one-liners to prepend the output of a command/pipe with the timestamp of when that line was 'printed'. However is there a ...
0
votes
1answer
490 views

Why does “cp -Rp ~/foo /Volumes/KINGSTON” give “cp: chflags: /Volumes/KINGSTON/Proj/Proj/Color.h: Invalid argument” [closed]

This is on Mac OS X Lion, and I use the following to back up a project folder cp -Rp ~/foo /Volumes/KINGSTON or cp -a ~/foo /Volumes/KINGSTON The -p or -a is so that the timestamps of the files ...
1
vote
1answer
640 views

Waiting until TCP socket is available in bash

Helli, I have a script that waits some time until a machine (being provisioned) comes up and then it connects to ssh and executes something. I use "sleep" for that. I would like change my script to ...
2
votes
2answers
377 views

How to manipulate accented files on Unix?

On our CMS that went through many versions and hosting platforms, we just came across an accented image file that would not work from it's url. So I ssh'd onto the box and tried to rename it. ...
4
votes
3answers
170 views

Moving files off volume and then back on while preserving all attributes?

I have a situation where I'm testing a new filesystem that has an issue with some metadata. All of the files are intact, however I ultimately have to effectively move every single file off to another ...
1
vote
2answers
280 views

Using wget and Awk to count similar expressions

I am trying to create a script that uses wget to download a data set and then awk to sort though the file and tell you the most common filter used which is $14 column. So far I have the wget function ...
3
votes
2answers
398 views

Shell background processes: what do characters in termination message mean?

I had three background processes, and here's what I've got: [1] Done zcat jan.txt.gz > j [2]- Done zcat feb.txt.gz > f [3]+ Done ...
14
votes
4answers
2k views

Can you have more than one ~/.ssh/config file?

We have a bastion server that we use to connect to multiple hosts, and our .ssh/config has grown to over a thousand lines (we have hundreds of hosts that we connect to). This is beginning to get a ...
2
votes
4answers
4k views

How to get the fully qualified name (FQN) on Unix in a bash script?

I have tested hostname on several servers (RedHat, Ubuntu), and hostname -f has proven unreliable, returning sometime the short name only (as described in this question). I can see the fqn in the ...
3
votes
4answers
1k views

What's a proper way of checking if a PID is running?

I have a .pid file, and I need to check if the process is running. So far I found two options kill -0 `cat something.pid` which prints out an error if the pid isn't running. I know this can be ...
1
vote
3answers
116 views

Why is ``head`` hanging and not terminating?

I have a shell script that has to find the newest file on a remote host. I have this bit: ssh -q $HOSTNAME -t ls -t -1 /path/to/somewhere/ | head -n 1 It prints the first line, then waits and ...
3
votes
5answers
678 views

How to monitor changes across several files in Linux?

I want to monitor changes across several log files in Linux. Basically, I want to see which log file gets updated out of a set of 20 files. I have checked multitail tool, but its UI can handle max up ...
3
votes
4answers
949 views

Bash script is not working as cron job

I have the following shell script $cat capture.sh TIME=$(date +"%H-%M-%d-%m-%y") IP="203.208.198.29" PREFIX=$TIME$IP tshark -f "udp" -i eth0 -w /root/captures/$PREFIX.cap& pid=$! sleep 2m ...
0
votes
1answer
77 views

Directory replication in New server

Scenario is to replicate all the directories,sub-directories,files,symbolic links present in Linux development Server to Linux QA Server. Lot of unix users also to be created. Consider an unix ...
0
votes
1answer
98 views

Use tar to exclude one directory (but not another) that matches a pattern

I'm working on doing a pretty straightforward tar for a site, but there's a wrinkle. Here's the file structure of the site: ... files/ images/ images/visitors/ ... logs/ ... ...
1
vote
2answers
535 views

I can run a script locally, but cannot do “ssh HOSTNAME /path/to/script.sh”

I have a linux server, and a linux desktop. I have written the following simple script to dump the database of a django web application: #! /bin/bash set -o errexit cd $(dirname $0) . ...
4
votes
3answers
99 views

Putting server configurations in version control via SSH

I have a bunch of *nix servers in production. I would like to put it's important configuration files in version control The basic idea I had was to Put a distributted version control system so ...
2
votes
2answers
53 views

Program output as an argument of another program

I'm reading Unix Programming Environment.There is a sample program echo "time is 'date'" with output as time is {current time} But in ubuntu's bash shell it is not giving output as expected.It ...
0
votes
2answers
299 views

Issues with echo commands?

I run this script as quanta suggest me #!/bin/bash EDATE=$(tail -1 a | awk '{ print substr($4, 2, length($4)) }') EEPOCH=$(date -d "$(echo "$EDATE" | awk 'BEGIN { FS = "[/:]"; } \ { ...
0
votes
2answers
298 views

extract information from a log file

I wrote a bash script to extract a few Items like the IP addresses that makes the most number of connection attempts, now I want to limit all of this within a time range , lets say the last 5 ...
1
vote
3answers
6k views

-bash: apt-get: command not found

Over the course of uninstalling the HP/palm enyo SDK and installing node JS I somehow goofed up something (I think my path). Now when I try use apt-get I get the following: -bash: apt-get: command ...
0
votes
2answers
262 views

Days since a specific date

How to print in linux/unix bash the number of days since a specific date till now? (for example days since 23rd of June 2009 till today)!
1
vote
1answer
246 views

Execute a Perl script after reboot on Solaris 10

During my activities on Solaris 10 machine I need twice reboot the Solaris unit and after reboot I'd like to run several scripts. Before first reboot I store in /etc/rc3.d/S99myScript some bash ...
6
votes
3answers
1k views

Non-recursive find on linux

I am trying to find all directories that are directly inside the current directory and older than a specific age. The trick is, I only want to consider the age of the immediate descendants of the ...
10
votes
3answers
324 views

How do I delete all empty directories

(on a Linux system) I have a large set of nested subdirectories on a filesystem. I would like to prune all directory paths that contain no files at all. In other words I would like to delete every ...
1
vote
3answers
344 views

how i can get the date in UNIX-aix and store ecah part in variable

I write batch file and i want to compare the modification time (timstap) to two folder and copy the latest one . i don't know if this option available directory be cause i don't know .so i want to get ...
1
vote
2answers
205 views

how to manage credentials/access to multiple ssh servers

I would like to make a script which can maintain multiple servers via SSH. I want to control the authentication/authorization in such a manner that authentication is done by gateway and any other ...
2
votes
5answers
1k views

How can I track growing directories?

I have a system that continually runs out of disk space. Im going to write a script that cleans up directories that grow larger. Usually these are log directories. Given the nature of the machine, i ...
4
votes
4answers
2k views

Combine multiple unix commands into one output

I need to search our mail logs for a specific e-mail address. We keep a current file named maillog as well as a week's worth of .bz2 files in the same folder. Currently, I'm running the following ...
0
votes
2answers
383 views

Bash scripting: Crossplatform check is package installed in the system?

For example I want to check does py-sqlite3 available..? One of the methods would to call that command with some minimum python script and catch error? I want to make check for any linux distro and ...