Solved

Unix/Linux basic script question

Posted on 2015-01-28
8
234 Views
Last Modified: 2015-02-18
I am getting the unix command out put and sending into a file, but it is putting all the info in one line.

echo `/sbin/lltstat -nvv active` >> $LOG

What am I doing wrong?
0
Comment
Question by:mokkan
8 Comments
 
LVL 9

Assisted Solution

by:Trenton Knew
Trenton Knew earned 188 total points
ID: 40575619
the command you have there would write the literal string to the $LOG file.  I think you need to remove the "echo" from the command
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 126 total points
ID: 40575624
Omit echo or use quotes:

/sbin/lltstat -nvv active >> $LOG

echo "`/sbin/lltstat -nvv active`" >> $LOG
0
 
LVL 9

Assisted Solution

by:Trenton Knew
Trenton Knew earned 188 total points
ID: 40575628
Just for clarification, are you trying to write the output of the lltstat command to a file?  $LOG is a variable, has it been defined?  echo '/sbin/lltstat -nvv active' will literally output "/sbin/lltstat -nvv active" to your $LOG file.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 126 total points
ID: 40575630
@Trenton - please look a bit closer.  The asker uses backticks, not single quotes.
That's what we call "command substitution".
0
 
LVL 9

Assisted Solution

by:Trenton Knew
Trenton Knew earned 188 total points
ID: 40575637
ah, sorry... my bash skills are still developing.
0
 
LVL 34

Assisted Solution

by:Seth Simmons
Seth Simmons earned 62 total points
ID: 40575642
$LOG is a variable, has it been defined?

if it wasn't defined, bash would have returned an ambiguous redirect
0
 
LVL 62

Assisted Solution

by:gheist
gheist earned 62 total points
ID: 40576140
It looks like a line from shell script, not a BASIC script.
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 62 total points
ID: 40576700
How the output of

/sbin/lltstat -nvv active | wc -l

looks like? Is it single line?
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
LogmeIn using Linux Ubuntu 16.04 6 104
The better OS Architecture 13 86
Linux MD5 Hash 7 59
Shrink Linux Swap File Size CentOS 10 18
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question