Results 1 to 6 of 6
i am writing this shell script which logs in remotely to my squid server checks the log file if its 7 days old, if it exist then copy it to ...
- 04-19-2010 #1Just Joined!
- Join Date
- Mar 2010
- Posts
- 6
shell scripting help
i am writing this shell script which logs in remotely to my squid server checks the log file if its 7 days old, if it exist then copy it to my machine to run a utility on the logfile
this is the script it
#!/bin/bash
# this script copies the access log file from the squid server copies it to 10.200.2.93 runs the sarg utility and the resulted report is sent back to server at /media/usbdisk/sarg_logs
locate=$(ssh -l root 10.200.2.28 | dir=/media/usbdisk/squid/access/ | file=$(find $dir -daystart -mtime
| echo $file)
#sarg -l $file
i can successfully login to the server but cannot check for the file and copy it to my machine
can someone help me
- 04-20-2010 #2
I think find is having difficulty interpreting the smiley face as an argument to -mtime. Try taking the sunglasses off it.
Seriously, you're not setting variables that you're using, you're not using variables you're setting, you're using in-line pipes in a way that makes no sense, and there's no semblance of an attempt to tranfer files from one machine to another. Try reading this and working your way up to the problem you're trying to solve:
Advanced Bash-Scripting Guide
- 04-20-2010 #3Linux Newbie
- Join Date
- Oct 2008
- Posts
- 140
fernfrancis, welcome to the forum. Please don't post more than one thread for this question. I hope you get the help you're looking for, I'm sorry that I can't help you with it, I don't know about that sort of thing, Kurt
- 04-20-2010 #4Just Joined!
- Join Date
- Apr 2005
- Posts
- 20
Have you tried putting the lines after the ssh command in a bash script and running it?
You are storing the return value in $locate but passing $file to sarg. $file will be undefined (return a blank)
- 04-21-2010 #5
instead of having login command in the script,you first login as root and then run the script.
- 04-21-2010 #6
$locate is unlikely to have anything useful, either, since the the parenthetic code to populate it makes neither logical nor syntactic sense.
It looks like OP is trying to code something in the fewest possible characters, but has not clearly thought through what steps need to be performed to accomplish the goal. The remarks look like those would be:
1) Find the file name of the log file on server A meeting criteria. NOTE: what if find returns more than one file name?
2) Copy the file from server A to server B.
3) Run the sarg command on the file.
4) Copy the sarg report to server x (might be server A, can't really tell).
Assumption: script is to be initiated on server B.
The code submitted doesn't appear even to contemplate 2 or 4. I'd suggest pseudo-coding your notion of how to accomplish your end result before trying to code it.
It's entirely feasible to have the script do the login and run the commands. I generally use PKI authentication to enable the login, but there are multiple ways to skin that cat.


Reply With Quote
