Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


Closed Thread
  Search this Thread
Old 04-19-2010, 06:37 AM   #1
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

# this script copies the access log file from the squid server copies it to runs the sarg utility and the resulted report is sent back to server at /media/usbdisk/sarg_logs
locate=$(ssh -l root | 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, 07:07 AM   #2
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, 08:22 AM   #3
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

#this script copies the access log file from the squid server copies it to runs the sarg utility and the resulted report is sent back to server at /media/usbdisk/sarg_logs
locate=$(ssh root@ 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 08:24 AM.
Old 04-19-2010, 11:08 AM   #4
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
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.

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-26-2008 11:50 PM
SHELL scripting/ shell functions mayaabboud Linux - Newbie 6 12-26-2007 08:18 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM
shell interface vs shell scripting? I'm confused jcchenz Linux - Software 1 10-26-2005 03:32 PM

All times are GMT -5. The time now is 11:36 PM.

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