Solved

Unix/Linux basic script question

Posted on 2015-01-28
8
229 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
 
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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 61

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now