LinuxQuestions.org
Visit Jeremy's Blog.
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


Reply
  Search this Thread
Old 08-08-2011, 04:48 AM   #1
dimothy
LQ Newbie
 
Registered: Jun 2010
Posts: 10

Rep: Reputation: 0
More scripting woes


So I have managed to get teh script I was working on in this thread to work. However I am now noticing some strangeness. When I paste the result I am one printer short from the list. On closer inspection I noticed that the first printer to be queried in the script was missing. Checked it was not commented out and ran the commands outside of the script to check they worked. Still nothing.

Ran a tail -f on the first text file I redirect to and it seems that it just skips over those two lines, no error or anything. Has anyone come across this before and are there any tricks to try and troubleshoot the issue further. Script below:

Code:
#!/bin/bash
echo PQ_CALMLABELS  >> printers.txt
snmpget -v 1 -c public 10.168.30.6 SNMPv2-SMI::mib-2.43.10.2.1.4.1.1 &>> printers.txt
echo TR3_1 > printers.txt
snmpget -v 1 -c public 10.168.30.1 SNMPv2-SMI::mib-2.43.10.2.1.4.1.1 &>> printers.txt

P.S. There are some sed commands at the end to remove and format the text but as I mentioned it does not seem to be adding them in to the first text file I create so sed never gets a chance to mess them up!!
 
Old 08-08-2011, 04:55 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
it's not skipping those lines, you're overwritting the file with the single ">" on the 3rd line.

use ">" to create / replace the file, use ">>" to append.
 
1 members found this post helpful.
Old 08-08-2011, 04:56 AM   #3
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
You have a single redirect here instead of a double.

Code:
echo TR3_1 > printers.txt
I don't think you want to overwrite the file at that point, do you?
 
1 members found this post helpful.
Old 08-08-2011, 06:53 AM   #4
dimothy
LQ Newbie
 
Registered: Jun 2010
Posts: 10

Original Poster
Rep: Reputation: 0
Ah, there is the problem. Really should drink less coffee and read the screen more!

Thanks for everything.
 
  


Reply


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: Scripting the Linux desktop, Part 2: Scripting Nautilus LXer Syndicated Linux News 0 02-17-2011 05:02 AM
Bash shell scripting woes..... gimpojones Programming 3 11-25-2009 07:51 PM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 05:29 AM
scripting woes Pestossimo Linux - Newbie 3 07-20-2005 01:43 PM
scripting woes slack9.0 the_cranky_don Slackware 10 11-03-2004 05:56 AM


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

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