LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Closed Thread
  Search this Thread
Old 04-19-2010, 07:37 AM   #1
fernfrancis
Member
 
Registered: Feb 2009
Location: Goa(India)-Sharjah(UAE)
Distribution: RHEL,centos,fedora,ubuntu
Posts: 229

Rep: Reputation: 18
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 8)| 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
 
Old 04-19-2010, 08:07 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
First rule of scripting: Try the commands first in interactive mode to make sure you know how they work.

In this case, I don't think you are using the pipe (|) correctly. A pipe is used to feed the output of a command to another command which is expecting input.
 
Old 04-19-2010, 09:22 AM   #3
fuorviatos
Member
 
Registered: Nov 2009
Location: Italy actually
Distribution: Ubuntu 9.10, Fedora 12, Free BSD
Posts: 33

Rep: Reputation: 16
I asked my brother who is much better in coding than me and he told me that the script should look like this

Quote:
#!/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 root@10.200.2.28 find /media/usbdisk/squid/access/ -mtime +8)
echo $locate
#sarg -l $file
He created a similiar script to yours, so if you need help in doing the same, he told me he can give you a hand

Last edited by fuorviatos; 04-19-2010 at 09:24 AM.
 
Old 04-19-2010, 12:08 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.

http://www.linuxquestions.org/questi...ys-old-802803/
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Terminal functions for shell scripting with Shell Curses LXer Syndicated Linux News 0 03-27-2008 12:50 AM
SHELL scripting/ shell functions mayaabboud Linux - Newbie 6 12-26-2007 09:18 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 03:14 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 05:29 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 04:32 PM


All times are GMT -5. The time now is 11:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration