UGN Security Forums
My ProfileMember DirectoryLogin
Search our ForumsView our FAQView our Site Rules
View our CalendarView our Active TopicsGo to our Main Page

UGN Security Store
 

Network Sites UGN Security, Elite Web Gamers, Back of the Web, EveryDay Helper, VNC Web Design & Development
July
Su M Tu W Th F Sa
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Our Sponsors
Latest Postings
Comcast upgrades Upload Speed!
by Gizmo
Today at 04:00 PM
Robert Moore aka MooreR PC Magazine Subscription
by Gizmo
06/22/08 01:36 PM
How to write a GUI with C++ in windows?
by Murakami Kakason
06/18/08 06:21 AM
Podcasting, ideas and interests...
by ZER0_DECEPTION
06/16/08 07:43 AM
PHP -MVC(Model, View, Control) overview
by §intå×
06/09/08 05:07 AM
Vote for President
by ZER0_DECEPTION
06/06/08 07:46 AM
Notepad++ 4.9.2 - open source text editor
by Gizmo
06/06/08 01:42 AM
Page 2 of 2 < 1 2
Topic Options
#16493 - 03/02/04 02:02 PM Re: Bash Tips and Tricks
Gizmo Administrator Online   shocked
Community Owner
*****

Registered: 02/28/02
Posts: 6894
Loc: Portland, OR; USA
hahaha, don't execute shutdown, it shuts down... note that you have to have autologin setup if you're maintianing the server remotely, otherwise when it boots it'll ask for the root user to login
_________________________
Donate to UGN Security here.
UGN Security, Elite Web Gamers & VNC Web Design Owner

Top
Our Sponsors
Sponsor Our Sponsors

Top  
#16494 - 03/02/04 03:30 PM Re: Bash Tips and Tricks
sinetific Offline
nobody

Registered: 03/02/02
Posts: 815
Loc: Ann Arbor
Gollum try using pidof [process] instead of ps

Top
#16495 - 03/03/04 12:03 AM Re: Bash Tips and Tricks
§intå× Administrator Offline
UGN Elite
*****

Registered: 12/03/02
Posts: 3241
Loc: here
Your shiting me. lol. Well I have a stand alone server.
_________________________
The individual is handicapped by coming face-to-face with a conspiracy so monstrous he cannot believe it exists.
J. Edgar Hoover

Top
#16496 - 03/03/04 01:50 AM Re: Bash Tips and Tricks
Gizmo Administrator Online   shocked
Community Owner
*****

Registered: 02/28/02
Posts: 6894
Loc: Portland, OR; USA
Yeh well I have 18 rackmounts ... all with autologin though heh...
_________________________
Donate to UGN Security here.
UGN Security, Elite Web Gamers & VNC Web Design Owner

Top
#16497 - 03/03/04 06:01 AM Re: Bash Tips and Tricks
pergesu Offline
Stoner Thugsta

Registered: 03/14/02
Posts: 1134
Loc: Pimpin the Colorizzle
What? No, you can just ssh in. It doesn't need to automatically login. It just needs to start up whatever services you want, including ssh, and then you can connect and control it remotely.

Top
#16498 - 03/20/04 01:06 AM Re: Bash Tips and Tricks
Gollum Offline
Member

Registered: 06/05/02
Posts: 207
Loc: US
just a question on the first one. doing:
for i in ls *gz
wouldn't that use 'ls' as a value for i.
i think the correct way would to leave out the ls and just do
for i in *gz
that should load all files in the current directory for i, as the for command looks for files anyway. thus the ls should not be needed.//
_________________________
Unbodied unsouled unheard unseen
Let the gift be grown in the time to call our own
Truth is natural like a wind that blows
Follow the direction no matter where it goes
Let the truth blow like a hurricane through me

Top
#16499 - 03/21/04 04:46 PM Re: Bash Tips and Tricks
Gollum Offline
Member

Registered: 06/05/02
Posts: 207
Loc: US
these are shell scripts i had to write:

used this one when after converting rtf files to html, i had to move and rename them. well i didn't have to rename them, but i did b/c it made me feel better. the filenames were .rtf.html, and i wanted just .html
moving multiple files and renaming them:

#!/bin/bash
for x in *.rtf.html #lists all converted html files in current directory
do
i=$(ls $x | cut -d. -f 1) #displays the filename up to the first period.
#for most files (in my case all of them) this will be the filename minus the extension
echo "Moving $i..."
mv $i.rtf.html /www/htdocs/$i.html #copy (or move, if you'd like to do that instead) all files to another directory and rename them
done


this second one i used to automatically generate a page of links to the files i just copied:

#!/bin/bash
rm index.html
for x in *.html
do
i=$(ls $x | cut -d. -f 1)
echo "$i
" >> index.html
done

pretty self explanatory. note that x is the full filename, and i is the filename without the extension.

i was setting up a large text section on my website, and so i used these two scripts in a cron job while having another program converting lots and lots of rtf files to html. it took a fairly long time, and so i set these up, so ppl could read the texts as they were generated and not have to wait for all of them to complete. speaking of which. does anyone know a really good rtf to html converter. i downloaded one that uses php. and yes it works. but it bloats the files big time. some of them end up being like 400-500k when all they need is 100k or so. needless to say very inefficient, especially when hosting from a cable connection. so if anyone has had any good results with certain conversion utilities, feel free to let me know.//
_________________________
Unbodied unsouled unheard unseen
Let the gift be grown in the time to call our own
Truth is natural like a wind that blows
Follow the direction no matter where it goes
Let the truth blow like a hurricane through me

Top
#16500 - 05/21/04 04:46 PM Re: Bash Tips and Tricks
sinetific Offline
nobody

Registered: 03/02/02
Posts: 815
Loc: Ann Arbor
Process Control

Something I find really useful especially logging in remotely is process controll. I might be explaining the ctrl-alt-del of unix here, but it was something I didnt figure out for like a year into my *nix life.

ctrl-c - kills a process
ctrl-z - stops or pauses a process and puts it in the background
& - launches a process into the background when it follows the command. ie: 'tail /var/log/apache/accesslog &' will write out new entries to the log file to your term window while you use it for other things
fg - places a stopped task into the foreground
bg - places a stopped task into the background

I find this usefull on bitchx or other command line irc clients that i can stop them, work in my shell, then resume chatting on irc. I also find & usefull for compiling programs. Send:
./configure && make && make install &
into the background as a background process and free up your term while it compiles and installs.

Top
#16501 - 05/28/04 01:27 AM Re: Bash Tips and Tricks
Wi1d Offline
Junior Member

Registered: 05/27/04
Posts: 3
Loc: USA
Quote:
Gollum try using pidof [process] instead of ps
Thanks, that worked nicely sinetific.
Code:
bye=`pidof xscreensaver` && kill $bye && echo proccess dies &#0124;&#0124; echo no such process
One of my favorites about bash is aliases.
Code:
# emerge aliases
alias emask="echo `$1` /etc/portage/package.keywords"
alias es="emerge -s"                                                   
alias ep="emerge -pv"
alias e="sudo emerge"
alias emerge='sudo emerge'
    
# directory aliases                                                    
alias ..='cd ..'                                                       
alias ...='cd ../..'                                                   
alias ....='cd ../../..'                                               
alias c="clear"
alias cb="bash_issue"
alias ls="ls --color=always"
alias ll="ls --color -l"                                               
    
# misc aliases
alias grep='grep --colour=auto'                                        
alias killwine="killall -9 wine; killall -9 wineserver"                
alias recal="history | grep `$1`"                                      
alias lock='xscreensaver-command -lock'                                
alias r00t='sudo -s -H'  
alias svi='sudo vim'
alias smv='sudo mv'
alias vi="vim"                                                         
alias nat="nautilus --no-desktop"                                      
alias 3d="sudo 3ddeskd  --acquire 700 2>1&"                            
alias screengrab="import -window root ~/screen.jpg"                    
alias lvim='vim -c "normal '\''0"'                                     
alias mkisofs="mkisofs -rJV"
alias torrget="btdownloadcurses.py --minport 50555 --maxport 65500"    
alias cal2="cal -3; echo -e Todays date is `date +%B\ %d`"             
alias scr="screen -r"
alias scl="screen -list"
alias nm="nmap -sS -O -PI -PT"
alias icq="screen -S icq centericq"
alias irc="screen -S irc irssi"
alias mp3="cd ~/music/full-albums/ && screen -S mp3 cplay"
alias get="cd ~/download/torrent-files/ && screen -S get"
_________________________
I sig not

Top
Page 2 of 2 < 1 2



Moderator:  Infinite 
Forum Stats
6899 Members
45 Forums
10167 Topics
44858 Posts

Max Online: 677 @ 06/30/07 10:06 PM
Top Posters
Gizmo 6894
§intå× 3241
UGN Security 3113
IceMyst 1445
SilentRage 1273
Ice 1146
pergesu 1134
Infinite 1039
jonconley 954
Girlie 903
Newest Members
real-along, Murakami Kakason, die, ReduX, UknownWarrior
6898 Registered Users
Who's Online
0 Registered (), 9 Guests and 19 Spiders online.
Key: Admin, Global Mod, Mod
Latest News
IRC Server Funding
by Gizmo
07/01/08 02:48 PM
Fixed: Front Page - News Display
by Gizmo
06/25/08 11:25 AM


Donate

Get the Google FireFox Toolbar
Get Firefox!
Get FireFox!