USA Linux Users Group Forum Index
Log in Register FAQ Memberlist Search USA Linux Users Group Forum Index Album

convert scroll to single line????

 
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » Shell Scripting and Programming
View previous topic :: View next topic  
Author Message
orphius
New Member


Joined: 25 Sep 2024
Posts: 9

PostPosted: Wed Nov 25, 2024 9:26 am    Post subject: convert scroll to single line???? Reply with quote

I would love to know how to convert the output of clamav from scroll to a single line readout. Any and all help would be appreciated. By the way I am wanting to do this in bash.



_________________
ArchLinux x86_64
Back to top
View user's profile Send private message
exiled
Jr. Member


Joined: 24 Nov 2024
Posts: 51
Location: ~/

PostPosted: Wed Nov 25, 2024 2:15 pm    Post subject: Reply with quote

You were kind of vague with that request, so I'll assume you want the total output on one line. If this is the case...
Code:
one_line=`clamscan -r /`
#substitute (clamscan -r /) with your clamscan command
echo -ne $one_line


Not sure if this is what you want, but it will put the total output as a single line. (basically removing the \n newline characters)



_________________
Currently: Frugalware, Fedora
Previously: Gentoo, Startcom, Debian, Sabayon, Mint, openSUSE, Mangaka Chu, #!CrunchBang
Back to top
View user's profile Send private message
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Wed Nov 25, 2024 3:08 pm    Post subject: Reply with quote

Alternatively:

Code:
 [YOUR COMMAND GOES HERE] | tr -d '\n\r'


or

Code:
 [YOUR COMMAND GOES HERE] | sed -e 's/\r//g' -e 's/\n//g'


implicit pipes are your best friend... Very Happy



_________________
ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)

PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
Back to top
View user's profile Send private message Visit poster's website
orphius
New Member


Joined: 25 Sep 2024
Posts: 9

PostPosted: Wed Nov 25, 2024 4:25 pm    Post subject: Reply with quote

sorry but none of those worked. I will try to explain better.
What i want is the output is on one line, changing with each file scanned. Not sure if it will help
but antivir scan used to do this. I'm not explaining well.



_________________
ArchLinux x86_64
Back to top
View user's profile Send private message
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Wed Nov 25, 2024 4:47 pm    Post subject: Reply with quote

alright then. I'm going to need examples since the words alone aren't quite working.

What is the output looking like now, and what do you want it to look like?

Also what is the exact command invocation that generated the sample output?

Software versions and Linux distribution will be most welcome information as well.



_________________
ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)

PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
Back to top
View user's profile Send private message Visit poster's website
orphius
New Member


Joined: 25 Sep 2024
Posts: 9

PostPosted: Wed Nov 25, 2024 5:11 pm    Post subject: Reply with quote

the command I am using is as follows:
( sudo clamscan -r -i -v --exclude-dir=^/sys\|^/proc\|^/dev\|^/mnt\|^/media\|^/zarchives\|^/personal/bckups\|^/personal/tarsave --remove=yes --detect-pua=yes / )

The only way I can describe what I want is that between each file scanned being output, a clear command is used or similar.
So that each file is displayed in the same space and line. First file, clear, second file, clear, third file, etc.
I would show you output, but I have no app that does it that way. I just know I have seen it done.

I am using Arch linux and Bash4
If you can't help because of my lack of being able to explain. No big deal and I appreciate the effort.



_________________
ArchLinux x86_64
Back to top
View user's profile Send private message
exiled
Jr. Member


Joined: 24 Nov 2024
Posts: 51
Location: ~/

PostPosted: Wed Nov 25, 2024 5:58 pm    Post subject: Reply with quote

Your output from clamscan is redirected into temp_file.txt
line by line is read from the file on a 2 second interval, replacing the existing line.
Substitute your clamscan command for the simple one I used,
you might also want to change the temp_file.txt path or sleep interval.

Any questions let me know Wink

Code:
#!/bin/env bash

clamscan -r /home > ~/temp_file.txt
while read line
do
  echo -e "$line"
  sleep 2
  clear
done < ~/temp_file.txt
rm ~/temp_file.txt



_________________
Currently: Frugalware, Fedora
Previously: Gentoo, Startcom, Debian, Sabayon, Mint, openSUSE, Mangaka Chu, #!CrunchBang
Back to top
View user's profile Send private message
exiled
Jr. Member


Joined: 24 Nov 2024
Posts: 51
Location: ~/

PostPosted: Wed Nov 25, 2024 6:16 pm    Post subject: Reply with quote

Just for fun...
Here is almost the same thing using tcl
Not sure if you need the exec before clamscan at the begining of the code
Good Luck Wink

Code:
#!/bin/env tclsh

exec clamscan -r /home > ~/temp_file.txt;

set var_file ~/temp_file.txt;
set var_handle [open $var_file r];

fconfigure $var_handle;
gets $var_handle var_line;

while {$var_line != ""} {
   puts -nonewline $var_line;
   flush stdout;
   after 2024;
   exec clear >@stdout;
   gets $var_handle var_line;
}
close $var_handle



_________________
Currently: Frugalware, Fedora
Previously: Gentoo, Startcom, Debian, Sabayon, Mint, openSUSE, Mangaka Chu, #!CrunchBang
Back to top
View user's profile Send private message
Lord.DragonFly.of.Dawn
Advanced Member


Joined: 18 Jul 2024
Posts: 607
Location: South Portland, Maine, USA, Earth, Sol System

PostPosted: Thu Nov 26, 2024 4:26 am    Post subject: Reply with quote

orphius wrote:
the command I am using is as follows:
( sudo clamscan -r -i -v --exclude-dir=^/sys\|^/proc\|^/dev\|^/mnt\|^/media\|^/zarchives\|^/personal/bckups\|^/personal/tarsave --remove=yes --detect-pua=yes / )

The only way I can describe what I want is that between each file scanned being output, a clear command is used or similar.
So that each file is displayed in the same space and line. First file, clear, second file, clear, third file, etc.
I would show you output, but I have no app that does it that way. I just know I have seen it done.

I am using Arch linux and Bash4
If you can't help because of my lack of being able to explain. No big deal and I appreciate the effort.


Thank you for your information. I still need a sample of what is being printed *now*. please provide such a sample output.



_________________
ArchLinux x86_64 - Custom Built Desktop
ArchLinux x86_64 - Compaq CQ50 Laptop
ArchLinux i686 - Acer Aspire One Netbook
ArchLinux i686 - Dell Presario ze2000 (w/ shattered LCD)

PuppyLinux, CloneZilla, PartedMagic, DBAN - rescue thumbdrives
Windows 7 (x86_64 desktop alternate boot)
Back to top
View user's profile Send private message Visit poster's website
orphius
New Member


Joined: 25 Sep 2024
Posts: 9

PostPosted: Thu Nov 26, 2024 8:22 am    Post subject: Reply with quote

exiles, neither of yours worked, got no output at all.

Lord.DragonFly.of.Dawn,
here is a sample of the standard output i am getting:

Scanning /personal/myscripts/instal3k
Scanning /personal/myscripts/templates/hw
Scanning /personal/myscripts/templates/toad
Scanning /personal/myscripts/templates/weather-short
Scanning /personal/myscripts/templates/hello
Scanning /personal/myscripts/templates/myswitches
Scanning /personal/myscripts/templates/mntunmnt
Scanning /personal/myscripts/templates/acheck
Scanning /personal/myscripts/templates/weather-long
Scanning /personal/myscripts/templates/motdmake
Scanning /personal/myscripts/templates/rlevel
Scanning /personal/myscripts/templates/bash-colors
Scanning /personal/myscripts/templates/bips.7z
Scanning /personal/myscripts/templates/bash-starter
Scanning /personal/myscripts/templates/alltemps
Scanning /personal/myscripts/templates/bash-tips

I hope this helps



_________________
ArchLinux x86_64
Back to top
View user's profile Send private message
exiled
Jr. Member


Joined: 24 Nov 2024
Posts: 51
Location: ~/

PostPosted: Thu Nov 26, 2024 1:05 pm    Post subject: Reply with quote

Ha! Ha! Ha!
orphius, how familiar are you with scripting?
You are running Arch, so I assume you know how to save, edit and make a script executable.
This is not rocket science, there are barely 6 lines of code there and I assure you those scripts are solid and do work.

Prior to posting, I successfully tested my scripts with 3 different inputs.
I don't have clamscan installed, but if it outputs as you have shown, both scripts will work.

Good luck to you...
and Happy Thanksgiving Very Happy

Now that I think about it...
How is it your running Arch and need help with such a simple script?
You are probably very familiar w/ the command line, what gives??



_________________
Currently: Frugalware, Fedora
Previously: Gentoo, Startcom, Debian, Sabayon, Mint, openSUSE, Mangaka Chu, #!CrunchBang
Back to top
View user's profile Send private message
orphius
New Member


Joined: 25 Sep 2024
Posts: 9

PostPosted: Thu Nov 26, 2024 1:47 pm    Post subject: Reply with quote

exiled.
I am very familiar with the command line and basic scripting. I have even
written some very basic ones. It just seems for some reason when ever I try
to figure this one out, I get brain freeze. Haven't you ever had that happen?
Or is it just me?

EDIT:
Just tried it again. This is what I came up with:

Code:
#!/bin/bash

clamall=(clamscan -r -i -v --exclude-dir=^/sys\|^/proc\|^/dev\|^/mnt\|^/media\|^/zarchives\|^/personal/bckups\|^/personal/tarsave --remove=yes --detect-pua=yes /)

${clamall} > ~/temp_file.txt
while read line
do
  echo -e "$line"
  sleep 1
  clear
done < ~/temp_file.txt
rm ~/temp_file.txt

its alittle slow, any way to speed it up a little?

EDIT:
Now all it will do is scan the active folder.
I think this is more trouble than its worth.
Thank you for the help Everyone!



_________________
ArchLinux x86_64
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    USA Linux Users Group Forum Index » Shell Scripting and Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All content © 2024-2009 - Usa Linux Users Group
This forum is powered by phpBB. © 2024-2009 phpBB Group
Theme created by phpBBStyles.com and modified by Crouse