Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Unix/Linux basic script question

Posted on 2015-01-28
8
Medium Priority
?
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 9

Assisted Solution

by:Trenton Knew
Trenton Knew earned 752 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 504 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 752 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 504 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 752 total points
ID: 40575637
ah, sorry... my bash skills are still developing.
0
 
LVL 35

Assisted Solution

by:Seth Simmons
Seth Simmons earned 248 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 248 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 248 total points
ID: 40576700
How the output of

/sbin/lltstat -nvv active | wc -l

looks like? Is it single line?
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

730 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