PowerUsers.info - Paul Doherty Askme Archive of Questions and Answers

Return to AskMe Archive Main Page

Return to Main PowerUsers.info Main Page

**********************************************************************

Category : Unix


QAId : 3231203
Asker : berhoomi
Subject : pick a line from another file
Private : No

Question : Hi,
I would like to know how to pick a line from another file. In other words, if I have a file called A.txt and I'm running a shell programming that will pick the first line from A.txt do some modification and then add it to file B.txt. Then picks the second line, do the same modification and add it to B.txt. Each line ends with a semicolon ";". The problem is how to pick line by line each time. The shell program supposes to pick each line using a while loop

Answer : So you are reading from A.txt line by line, modifying each line in some way and then sending those changed lines to a new file B.txt, right? Here is the structure for that:

#!/usr/bin/ksh

cat A.txt | while read line
do
#modification stuff
# on each "line" go here
echo $line >> B.txt
done

That's it - so for example let's say you were going to read in all the lines of A.txt and make all the characters in each line uppercase and output the results to B.txt.

#!/usr/bin/ksh

cat A.txt | while read line
do
echo $line | tr "[:lower:]" "[:upper:]" >> testfile2
done

--
Paul Doherty, CNA, CNE, MCP+I, MCSE, A.A., B.A.
http://members.home.net/iqueue
Home of PC DiskMaster and other Windows utilities




Answer : In the last example that "testfile2" should be "B.txt" to fit the example.


Rating : 5


----------------------------------------------------------------------
QAId : 3373769
Asker : Anonymous
Subject : write zero byte in unix
Private : No

Question : Anyone know the command to write every files (including and not including the sub-directory) into zero byte under unix?

Answer : It sounds like you are trying to empty out files that already exist?

If so...

For the files in your current directory only:

ls | while read item
do
cat /dev/null > $item
done


For all the files in the current directory *and* all files in all subdirectories:

find . | while read item
do
cat /dev/null > $item
done

--
Paul Doherty, CNA, CNE, MCP+I, MCSE, A.A., B.A.
http://members.home.net/iqueue
Home of PC DiskMaster and other Windows utilities

Rating : 4

Answer : Just curious... (3 stars) In what way did that *not* answer your question?

FUQuestion : Even I wondered the 3 stars because I remembered I click on 5 stars after testing. However, thank you very much for your help.

Answer : No problem... I feel better now. I had wondered how that could be construed to be less than a "full" answer. Thanks for clearing it up.. :-)

--
Paul Doherty
http://members.home.net/iqueue

Rating : 4


----------------------------------------------------------------------
QAId : 3448592
Asker : i237
Subject : Complie
Private : Yes

Question : Hi,
I'm a begingner learnig unix and c.
I have a quesion,
how can I complie the c in unix.

for examplie ,
what command should I type to compile the hello.c

thanks in advance

Answer : Either:

cc hello.c

or

gcc hello.c

depending on which compiler you have installed. Do a:

which gcc

which cc

and see which gives you a response.

--
Paul Doherty
http://members.home.net/iqueue

Rating : 5


----------------------------------------------------------------------
QAId : 3483152
Asker : Anonymous
Subject : Sendmail
Private : No

Question : Dear pauldaherty,

Where i can get documentation or resource on how to configure/setup sendmail as SMTP server.

Thanks

Answer : Did you try the main page for sendmail?

http://www.sendmail.org/


--
Paul Doherty
http://members.home.net/iqueue

Rating : 3


----------------------------------------------------------------------
QAId : 3739490
Asker : Anonymous
Subject : unix
Private : Yes

Question : is the Unix operating system's standard user interface, GUI, similar to that of the Macintosh and windows system?

I just want to know if it is true or false, no explanation necessary

Annonymous - who gives generous ratings

Answer : They're as different (and as similar) as GUIs can be - they both have mice, pointers, windows and menus, but beyond that they configuration and use of them is as different as can be.

--
Paul Doherty
http://members.home.net/iqueue

Rating : 5


----------------------------------------------------------------------
QAId : 3761398
Asker : subirp
Subject : unix
Private : No

Question : I wanted to know if I can untar a file to a different location than
where the tar file is. The tar file does not have a absolute path. For instance:
# tar tvf dazel.tar
would install the following files under the
current directory. I do not have enough space to put the tar file
in the file system that I want to install the files in.
# tar tvf dazel.tar
rwxr-xr-x 2/2 163360 Jun 18 20:10 1998 dazel/repository/bin/lpr
rwxr-xr-x 2/2 376480 Jun 18 20:10 1998 dazel/repository/bin/mkoiddb

Answer : No problem - the tarfile will extract to where you are. So if the file is in /tmp do this:

cd /whereever/you/wanttoextract
tar -xvf /tmp/myfile.tar

Paul Doherty
http://members.home.net/iqueue
Rating : 3.3
Rating : 3.3
Rating : 3.3


----------------------------------------------------------------------
QAId : 3793170
Asker : akkha
Subject : systems
Private : Yes

Question : Dear Sir/Madam

Can you tell me the different between networked systems and distributed systems?

ps. am i in the right category, if not pls tell me which category should i ask.

Thanks in advance

Answer : I would say the difference is that "networked" systems are ones who are linked by networking hardware but may or may not have anything to do with each other in a functional sense, whereas a "distributed" system is one that uses multiple systems, connected by a network, to perform a particular function.


--
Paul Doherty
http://members.home.net/iqueue



----------------------------------------------------------------------
QAId : 4362683
Asker : aberjel
Subject : unix for x386
Private : No

Question : i'm intended to install unix on 80x386 computer
and so far as i know that there's just minix can be installed on such a machine .

i want to know if there's any kinda of unix or unix like to install on it .

Answer : If by "x386" you mean an Intel processor machine running the X86 architecture (which includes 386, 486, Pentium, II, II, IV CPUs and more) you may want to look at other UNIX-like offerings:

Linux:
http://www.redhat.com
http://www.suse.com
http://www.mandrake.com
http://www.linux.com

BeOS:
http://www.be.com/products/freebeos/

FreeBSD:
http://www.bsd.org/


--
Paul Doherty
http://members.home.net/iqueue



----------------------------------------------------------------------
QAId : 4381728
Asker : domenic_colantoni
Subject : Backup Command...
Private : Yes

Question : On digital Unix I use the vdump command to backup our filesystems. (ie. were you get to input the level of backup to perform 0-9)

I understand there is a similar command for the Sun operating system...

Would you know what it is?

Thanks in advance

Domenic

Answer : I think the command you are looking for is ufsdump...

--
Paul Doherty
http://members.home.net/iqueue
Rating : 5


----------------------------------------------------------------------
QAId : 4384948
Asker : jatanag
Subject : how to start unix without keyboard
Private : No

Question : How can automatically reboot unix without keyboards.

Answer : One way...

Use

crontab -e

(be sure EDITOR is defined, as in EDITOR=/usr/bin/vi;export EDITOR)

and schedule a reboot for the time you want.


--
Paul Doherty
http://members.home.net/iqueue





----------------------------------------------------------------------
QAId : 4434633
Asker : john2069
Subject : Memory usage on Solaris 2.7
Private : No

Question : Does Solaris have a command that shows the memory usage for specific processes?

I have a process that I suspect has a memory leak. When several of these processes are running, memory appears to be used in increasing amounts.


Answer : Two ways:

ps -efyl | grep myprocess

OR

Use the 'top' utility which will show the top offenders in terms of resource usage.

--
Paul Doherty
http://members.home.net/iqueue
Home of PC DiskMaster and DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 4676536
Asker : Anonymous
Subject : UNIX
Private : No

Question : where can i find comparison of how fast different operating systems run at.UNIX,NT,Win9x,etc..
can't find it anywhere.And also how do i find out which file contain the ip address of the server I am currently connected to in unix?
thx in advance

Answer : Try the command:

ifconfig -a

Speed tests of various operating systems:

http://www.google.com/search?q=speed+tests+solaris+windows+nt+linux

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 4765862
Asker : f.boies02017
Subject : Some commands
Private : No

Question : I'm a beginner in Unix, could you give me a help and tell me what these commands are used for:

rm, rmdir, date, pwd, free, user, w, who, more, | (pipe), exit, reboot, shutdown, mount, umount, find touch, logname, passwd, su and tar.

Thanks a lot

Christian

Answer : That is too many for me to detail here - it would take several pages of typing to adequately explain all of those. Check here for people who already have:

http://www.google.com/search?q=unix+commands+explanation+ls+mkdir+shutdown+rm


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 4789806
Asker : yannanqi
Subject : How to create a user that has the same UID as another user account?
Private : No

Question : pauldoherty,
I have a question about unix to trouble you.That is:
How to create a user using "useradd" command that has a UID same to another user that already exists?

For example ,I have already created a user account "user_one",and its UID is 201.Now I want to create another user account "user_two",and its UID is also 201. I tried "# useradd -d /usr/user_two -u 201 user_two",but I failed.Can you help me?

Thank you very much.

Answer : Just vi the two following files (as root) and copy and paste the lines for the user you're attempting to duplicate, then change each occurrence of the old name in the copied lines to the new user name:

/etc/passwd
/etc/shadow

Afterwards issue:

passwd newuser

where 'newuser' is the name of the duplicate user.

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 4822711
Asker : Anonymous
Subject : how do i change the network settings in UNIX
Private : No

Question : I just started using UNIX last week and I need to change/add DNS #'s to the Network Settings, but I cannot find out where or how to modify the network settings. I'm using the OS Solaris 8.

any help would be Greatly appreciated.

Answer : You will need to edit these two files:

/etc/resolv.conf
/etc/nsswitch.conf

In nsswitch.conf find the line that has "hosts" at the beginning and make it say:

hosts: files dns

In the resolv.conf (make it if it doesn't exist) you will need these lines:

domain blah.blah.com
nameserver ip_address_of_dns_server_1
nameserver ip_address_of_dns_server_2
search first.com second.com

The first.com and second.com indicate what domains should be searched automatically when you type a name in - for example if a machine is named (in DNS) machine1.first.com with the above lines in place you will successfully find its IP address without using its fully-qualified name.

Fully-qualified name:
machine1.first.com

With the resolv.conf lines in place can be gotten as:

machine1

so both of these next lines would work:

ftp machine1.first.com

ftp machine1



--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 4848780
Asker : Anonymous
Subject : unix editor
Private : No

Question : Hi All,

I noticed a user using their cursor keys while
editing scripts via vi. How is this possible?
Do I need to be in a different shell?
Do I need to set my environment prior to editing
vi?

Thanks in advance


Answer : I assume you mean they were using the cursor keys and such to edit *at the command line* with vi commands? That is done by setting the appropriate environment variables. I always set these two in my .profile file:

VISUAL=/usr/bin/vi;export VISUAL
EDITOR=/usr/bin/vi;export EDITOR

I also use ksh (Korn shell).

Thereafter you can treat the command line just like a vi session - hit ESC and you're in command mode, and "i" for insert, "a" for append.


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities


Rating : 5
End :


----------------------------------------------------------------------
QAId : 4929290
Asker : thd1811
Subject : Preferred way for disk layout on Sun machine
Private : No

Question : I have been installing Solaris 7 on sun machines(Ultra10's 60's) and wanted to know what is the preferred way to layout a disk. I usually have autolayout do the initial and then customize from there. Some questions I had are::

Why does it always put the minimum in the root / partition? Esp. if var isn't on a different partition, then it usually runs out of space for patches.

Is there a good reason to put /opt, /usr/openwin, or /var on their own partition?

Where does it get the amount for the swap space?

thanks,

Answer : I agree the default root is never adequate. I tend to isolate the /var and /tmp (swap) filesystems and let root have the rest. I can see that putting /opt and /usr in their own can be a good thing too though. It can make replacing failed drives or adding space to them easier if they are not part of the root filesystem.

I am not sure of the rule of thumb employed in choosing the size of swap (if that was what you meant). I usually go for 1-2X RAM, whichever I can afford in disk space.

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities

Rating : 4


----------------------------------------------------------------------
QAId : 4961243
Asker : thd1811
Subject : How can I tell which shell I'm in??
Private : No

Question : How can I tell which shell I'm in??
I used to be able to just tell by the prompt whether it was %,#, but now we have other shell variant like the tch, bash and zsh, is there a cmd that will tell me exactly what shell I'm currently using? Thanks,

Thomas

Answer : echo $0

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities

Rating : 3.9
Rating : 3.9

Answer : Well, what are you doing in csh??? hehe ;-)

FUQuestion : Yeah, I know, but some people here use it as their default shell, I have to deal with everybody's preferences. :)

Answer : No answer required - :-)


----------------------------------------------------------------------
QAId : 4966062
Asker : yannanqi
Subject : Why "rsh" doesn't work?
Private : No

Question : Hi,pauldoherty.
I have a problem to ask for you:
By setting file .rhosts,I can use "rcp "command
to operate on remote host "host1" from "host2".
But when I use "rsh " command ,it gives error
messages as:"host1:host1 cann't open".
Can you solve the problem for me and tell me how
to execute some commands on remote host?
(host1: SCO OpenServer 5.0.5
host2: SCO OpenServer 5.0.5)

Thank you.

yannanqi.

Need More Information : "host1:host1" doesn't make sense to me in an rsh command. Can you show me what your command looks like exactly?

It should appear like this:

firestone $ rsh lizard cat /etc/lizard.file >> firestone.file

This run on the system named firestone would have the effect of appending the text in file /etc/lizard.file on the system named lizard to the file firestone.file in the current directory on firestone.

For this to work without fully-qualified names you would need corresponding entries in each machines /etc/hosts file for it to resolve the other's name.


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

FUQuestion : All right.I will give you my cofinguration as below:

1.host1(remote host): IP:144.88.8.1 name:host1
/etc/hosts : 144.88.8.2 host2
...
/etc/hosts.equiv: host2
/usr/user1/.rhosts: host2

2.host2(local host): IP:144.88.8.2 name:host2
/etc/hosts: 144.88.8.1 host1
...
3.the command I executed on local host(host2) is:
$rsh host1 ls /tmp
4.the error message is:
host1:host1:can not open

Need More Information : Do you have /etc/nsswitch.conf configured to look to "files" before dns?

What is in your /etc/hosts.deny and /etc/hosts.allow files?

Have you considered installing ssh and using it's programs instead (as a secure alternative - ssh, scp slogin)?

http://www.ssh.org/faq.html
http://www.freessh.org


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

FUQuestion : I didn't find files/etc/nsswitch.conf,/etc/hosts.deny and /etc/hosts.allow.

What's ssh? What's its usage? Can you tell me something about it and where to download it and how
to install it?

Thank you.

Answer : The links to the download and docs are in the message I sent you above. After you install or compile/ionstall it ssh should be in /usr/local/bin and consists of replacement utilities that do the same things as rcp/rsh/rlogin but in an encrypted and secure manner.

The commands are scp/ssh/slogin - "secure" versions of the same-named commands.

To use them as a user simply inlcude /usr/local/bin in your PATH, make a .ssh directory in your home dir (where the SSH connects to hosts configurations are kept) and start connecting with other machines that have SSH installed.

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities

FUQuestion : I download file "fressh-0.8.1.tar.bz2",how to uncom-
press it? It's not .Z file.
Rating : 5

Answer : You'll need bunzip2 (ensure you don't already have it - my Solaris 8 machine does):

http://www.google.com/search?q=bunzip2+bz2+download&hq=&hl=en&lr=&safe=off

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 5001680
Asker : hgil21
Subject : permmisions on files
Private : No

Question : hi ! How are you ? I got a question..

any files or directories like below with no permissions to users to read these files. How can users know that how big these files are. Or what informations users can have about these kind of files or directories. thanks


-rw-r----- 1 applmgr applmgr 74 Sep 28 1998 afiedt.buf
drwxr-x--- 2 applmgr applmgr 24 Sep 19 1999 core_21330
drwxr-x--- 4 applmgr applmgr 1024 Oct 6 1998 gar
drwxr-x--- 2 applmgr applmgr 1024 Sep 28 1998 sql

Answer : The file cannot be read or have its contents displayed by anyone not in the applmgr group, or the applmgr account itself.

The directories cannot be entered by users unless you give "other" the read and execute permissions, or they are a member of the applmgr group. In fact even if you have files to which the user would normally have access (like read permissions to a text file inside one of those directories) they will be unable to examine those files if the directory permissions are set the way they are above.


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 5006960
Asker : thd1811
Subject : /home directory question
Private : No

Question : I have this machine I took over from another admin
and it has a /home directory with a lot of other peoples account names in them, they are large and thought I can delete them but it says permission denied even though I'm logged in as root. I can't do anything with them, chmod, chown, etc. what are these directories?


Answer : If you are root you can get rid of them. Try it this way - assume that /home/user1 is the home directory a user named 'user1':

cd /home
rm -Rf user1

Be careful as the whole subdir branch will be gone.
Rating : 5


----------------------------------------------------------------------
QAId : 5006999
Asker : dreamlink
Subject : What i have to do to compress/uncompress a unix directory /test via gzip or tar
Private : No

Question : What i have to do to compress/uncompress a unix directory (i.e. /test) via telnt using gzip or tar ?
Thank you

Answer : If you have a file that looks like this:

file1.tar

it's just tarred and you can extract it like this (assume that file1.tar is in your /home/user dir):

cd /tmp (or wherever you'd like the file extracted - can be the same dir as the tar file)
tar -xvf file1.tar

If the file looks like this:

file1.tar.gz

it's been tarred and then compressed with gzip as you mentioned. To get it out you can do this:

gunzip file1.tar.gz
tar -xvf file1.tar

OR if you have gzcat available you can leave the archive intact and get at the insides like this:

gzcat file1.tar.gz | tar -xvf -


Also sometimes you may see files like:

file1.tar.Z

This file was tarred and then compressed with "compress" - to get at it:

uncompress file1.tar.Z
tar -xvf file1.tar

Paul Doherty
http://members.home.net/iqueue
Rating : 5


----------------------------------------------------------------------
QAId : 5021692
Asker : yannanqi
Subject : How to use SHELL variables in awk
Private : No

Question : Hi,pauldoherty.
I have a question to ask you,that is:
In awk,how to invoke shell environment varialbe?
For example,I want to merge environment variable
VAR1 and $1 of awk, I write the following wrong
command to express myself:
# awk '{print $VAR1,"-->",$1}' /etc/passwd

I know I can't simply use $VAR1 because awk has masked "$" by ' '.So what should I do to let awk
not mask "$"?

Thank you.

yannanqi.

Answer : Here is a conversation thread on the topic:

http://groups.google.com/groups?hl=en&lr=&safe=off&th=84edbeac5a2ed140&start=0&ic=1


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 5033881
Asker : Anonymous
Subject : Questions about UNIX command
Private : No

Question : What's the difference between commands "print" and "echo"?
What's the usage of commands "cd ~", "cd -" and "cd ~-"?
Thanks for your attention!

Answer : Well print is an executable and echo is usually a shell built-in function. print also accepts more parameters that modify it's functionality. See "man print" and "man echo" for more details.

cd ~

means take me to the current user's home directory (does not work in all shells - may be a Linux-ism in bash)

cd -

means take me to the last directory I was in

cd ~-

I've never heard of this one and since it equates to two paths at the same time I'm not sure it's valid.


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 4
Rating : 4


----------------------------------------------------------------------
QAId : 5097087
Asker : Anonymous
Subject : compress all files and folders in a directory
Private : No

Question : Hi,

A quick question, how can i compress all files (including other folders) inside a particular folder?

gzip myfile * -only works on files inside the current folder and does not include folders

Thank you.

Answer : Try this (assuming you want to archive the /var/stuff directory and all files/dirs beneath it):

cd /var/stuff
tar -cvpf ..\stuff.tar .
cd ..
gzip stuff.tar

Now you have a file called stuff.tar.gz that contains a compressed version of all your subdirectory structure including all permissions. To retore it (to the same or a different system) ensure the /var/stuff dir exists, then:

cd /path/to/archive
gunzip stuff.tar.gz
cd /var/stuff
tar -xvpf /path/to/archive/stuff.tar

And everything is back!

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities

FUQuestion : The first command worked fine, but now i can't find the .tar file.

any ideas?

Answer : Oops - realized I have a backslash instead of a forward slash in the tar command - change that from

tar -cvpf ..\stuff.tar .

to

tar -cvpf ../stuff.tar .

After the first two commands:

cd /var/stuff
tar -cvpf ../stuff.tar .

you will have created a 'stuff.tar' file in the directory above the one you're in. (You can also tar to any other directory you like by using it in place of "../" like /tmp/stuff.tar) That's where the next command:

cd ..

comes in - it moves you up one directory to where the file exists. then you compress that file with:

gzip stuff.tar

and gzip compresses the file into stuff.tar.gz and deletes the original .tar file.


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



Rating : 4


----------------------------------------------------------------------
QAId : 5172809
Asker : p.kinsella@...
Subject : installing solaris 8
Private : No

Question : Hi,

I am trying to install solaris 8 on a sun microsystem ultra 10 elite 3D with two hard drives. It lets me enter all the info and then tells me that the name server is wrong it seems like its a hard drive problem.

heres the partition layout

o. c0t0d0 <seagate medalist 34342a cyl 8892 alt 2hd 15 sec 63> /pci@1f,0/pci@1,1/ide@3/dad@0,0
1. c0t1d0 <ST34342A cyl 8892 alt 2hd 15 sec 63> pci@1f, 0/pci@1/ide@3/dad@1,0

heres the full map

part tag flag cylinders size blocks

0 unassigned wm 0 0 (0/0/0) 0
1 swap wu 0-1109 512.18Mb (1110/0/0) 1048950
2 backup wm 0-8891 4.01GB (8892/0/0) 8402940
3 unassigned wm 0 0 (0/0/0) 0
4 " " " " " "
5 " " " " " "
6 " " " " " "
7 " " " " " "
I'm not sure how to prepare the disk if it isn't prepared properly.
can you advise?

thanks

Pat

Answer : That is a known bug with Solaris 8's install. It will never succeed at this point in the install if you select DNS. Just start a new install and select "no name service" when asked. After the install add the DNS info you need in the form of:

/etc/nsswitch.conf
/etc/resolv.conf
/etc/defaultdomain
/etc/hosts


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

FUQuestion : Hi,

thanks for the info do i just edit these files and put in my ip addresses? And finally
what book should i get if i want to be a solaris expert?

many many thanks

pat


Answer : Well it's a bit more than that. You'll need to find the line in nsswitch.conf that looks like this:

hosts: files nis

and make it like this:

hosts: files dns nis

(and remove nis altogether if you like)

In resolv.conf you'll need this:

domain wherever.com
nameserver 214.24.38.32
nameserver 214.24.38.33
search wherever.com

In the above info you'll use your own DNS domain and name server addresses.

/etc/defaultdomain is just a text file with the domain name (same as in the file above) in it.

/etc/hosts will contain information about any hosts (including your own machine) that you need to know about even if DNS fails.

For example:

#
# Internet host table
#
127.0.0.1 localhost
10.1.1.9 elfstone elfstone.wherever.com loghost

"elfstone" is the local machine I am configuring.

Finally you will need a file called:

/etc/nodename.xxx

where 'xxx' is the device name for your interface card. You can find it by typing:

ifconfig -a

"lo0" is the loopback device and can be ignored. We're after the other one - like hme0, or le0. Once you determine which it is make the file as above and put the hostname of your machine in it on a line by itself.

Reboot after this and you should be in business.

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities



Rating : 5


----------------------------------------------------------------------
QAId : 5186526
Asker : takkie
Subject : RE: changing shells
Private : No

Question : Hi all
I am new to UNIX systems, and my professor told us to change our default login shell to ksh (our default is bsh). He said there are 2 ways to do this. And i figure it is changing the .profile by adding a line chsh ksh and at the prompt, type chsh ksh. Now here is the probelm, how can i get back to bsh as my default login shell??
i try to do chsh bsh but it says bsh is not an accceptable new shell. What should i do??
2. I used ex to change the .profile file and add the line chsh ksh. I accidently hit the backspace key and it came out ^H^H^H symbol. How can i delete those characters?? it is now in my .profile file....what should i do??? I was using telnet to do that....
please help.
@takkie

Answer : 1) I think you mean "bash" not "bsh".

2) Some terminals have screwy settings for the backspace key - usually pressing CTRL-backspace or CTRL-DEL will get the effect you're after. You can change the effect of the backspace key by typing this at a prompt:

stty erase (press the backspace key, then ENTER)

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities





Rating : 4


----------------------------------------------------------------------
QAId : 5189608
Asker : eo
Subject : unix: how can I trigger a perl script to execute every 12 hours?
Private : No

Question : how can I trigger a perl script to execute every 12 hours?

linux environment, bash

Answer : Create the perl script with the first line appearing as:

#!/bin/perl

(assuming that after doing a "which perl" you get back /bin/perl for a path)

Then as whatever user you want this script ro run do a "crontab -e" and add this line to the bottom:

0 0,12 * * * /path/to/script/myscript.pl

Save the file and it should now be run every 12 hours.

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities

Rating : 3.9

Answer : And what exactly about this answer differs from the one you gave a 5-star rating to?
Rating : 3.9


----------------------------------------------------------------------
QAId : 5256757
Asker : takkie
Subject : RE: user prompts
Private : No

Question : hi all, please help!!
1. can i set up something like dos prompt in korn shell? what i mean by dos prompt is whenever you are at a directory, it shows you where you are..for example, for dos is 'c:/dir/2dir/3dir>" where 3dir is your current directory. If you do a 'cd..' the prompt will look like this 'c:/dir/2dir>'...can i do the samething with korn shell??? I want it to be like this: '$/usr/my-dir>' where mydir is the current directory and samething like the dos example, do a cd.. will bring back to parent directory and the prompt will correspond with it.


2. can i do the samething like #1 using C-shell?

3. If you create a new.bat in dos, and you put the dos command in it. after you save the new.bat, the next time you just have to type new.bat instead of typing all the commands....can i do the samething with C-shell??? is there anywhere i can create some files like a batch file using c-shell?
for example, i dont want to type 'ls -alf' all the time, i want to just type in 'newls' and it will execute 'ls -alf' for me. And i want to seperate the commands with semi-colon instead of using the pipe operator. that is, 'newls; newls2', where newls and newls2 is the batch file made in C-shell.

SOrry to bother you guys and please help!

@takkie

Answer : I use something like the following in /etc/profile to give all users except root a custom prompt:

if [ "$LOGNAME" = "root" ];
then
PS1="# ";
else
PS1='[$LOGNAME@]'elfstone'] $PWD $ ';
fi;
export PS1

This will give a prompt like this:

[ped@]elfstone] /export/home/ped $

which will show the current directory as you move around. Move the pieces around to make your own.

For csh try this one:

export PS1="$(uname -n)%($PWD)"

Make a directory under your home dir called "scripts" and then add that to your PATH. Once you have that done you can add scripts to that dir and they will run when you type them. To create the one you mentioned:

cd /export/home/myname/scripts
vi newls
(add the following)

#!/usr/bin/ksh
ls -alf $1 $2

Now do this:
chmod 755 newls

Now you can try the command.

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 5263744
Asker : mmangano
Subject : Creating root equiv. accounts on Solaris 7
Private : No

Question : Hello,

I am having trouble figuring out how to create a root equivalent account under Solaris 7.

Not sure what command to use?

Thanks,

Mark

Answer : Just edit the following files and copy the lines for the root user:

/etc/passwd
/etc/shadow

In the passwd file make sure you rename the "root" to the new username. Here is the original line:

root:x:0:1:Super-User:/:/sbin/sh

Changed to the new one:

goober:x:0:1:Super-User Also:/:/sbin/sh

Here is original root line from the shadow file:

root:3KOV5gH3JFzkY:10528::::::

and the changed one:

goober:3KOV5gH3JFzkY:10528::::::


Now while you are still root do a:

passwd goober

and give him a new password (preferably a GOOD one since he's root-equivalent).


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 5274304
Asker : rube2
Subject : Changing IP on hme1
Private : No

Question : Hi, Paul!
I inherited a Sun220R to admin. IPv4 on Solaris8. It has 2
ethernet interfaces set to local 'reserved network' static IP numbers. I'm being asked to put this machine on the outside of the firewall temporarily for testing. I can plug it into a hub for this purpose. I have an external IP number, netmask (not in hex though), and gateway router to point to for the hme1 interface.
'ifconfig -a' shows me the IP, netmask etc. I can 'ifconfig hme0 down' to take down temporarily the primary interface.
How do I change the address of the hme1 interface? What commands must be invoked to change the address so that I can then unplug it from the internal switch and plug it into the external hub? Do I have to reboot the 220R for this to change?
Can't seem to find a straight answer on Sun's BigAdmin.
Ultimately, I'd like to make this machine a multihomed host - hme0 live to the inside and hme1 live to the outside. There should be no packet forwarding between interfaces and I don't want this to be a router, but then this machine would be available for testing by engineers.
If you can help, thanks!
(please cc reply to kenzo562@iname.com if possible...)

Answer : You won't need a reboot - you just need some more ifconfig commands. To change the IP of an interface do it like this:

ifconfig hme1 123.12.13.14 netmask 255.255.255.240 up

Make sure your default router (gateway/router port) is defined on a single line in /etc/defaultrouter and that your netmasks are defined in /etc/netmasks.

To stop the machine from routing you only need to do this:

touch /etc/notrouter

and reboot.

To be really sure it doesn't get turned on disable the routed daemon in /etc/inet/services.

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities

Rating : 5

FUQuestion : Thanks for your quick response!
In /etc/netmasks, I have the original
<subnet> <netmask> in place:
172.16.0.0 255.255.255.0

Do I add the lines of the outside network right under the lines of the internal network as part ofthe process of moving the machine outside of the private network? That would be:

63.81.163.xxx 255.255.255.240

About /etc/defaultrouter: Is running:

# /usr/sbin/route add default 63.81.163.yyy 1

....the way to add a line in /etc/defaultrouter?

Thanks!

Answer : Yes just add lines as needed to /etc/netmasks for each network interface. Follow the same format as the line you quoted. Your new line would then be (if that was indeed your network and subnet mask):

63.81.163.0 255.255.255.240

Any access to a 63.81.163.0 address, or any interface that talks on a network listed in netmasks, will be assumed to use that netmask unless overridden by an ifconfig statement later.

I don't think you will want to be running route statements after disabling the routed daemon and touching the /etc/notrouter file. Just create a single line text file /etc/defaultrouter that has the IP of the interface you want to go to as your default. So for instance it might be:

63.81.163.1

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities


FUQuestion : Thanks Paul!
Turns out that the ethernet interface on the motherboard is multihomed with two internal addresses.
I shut down both, detached the wire from the internal switch and attached it to the external hub, assigned hme1 the external address and it was pingable from the outside. I did not change the defaultrouter content which is an internal address but it still worked. Can defaultrouter have two lines with unique addresses?

In the future, I'd like to remain connected externally and use the second physical interface connected internally but I don't want the fat pipe from the external thru the CPU to the internal. Will turning off packet forwarding accomplish this or is it just too dangerous once the CPU is penetrated?

Answer : Yes, just add extra lines for the backup default routes to defaultrouter and you're set.

As for packet-forwarding. Yes I'd lock that machine down if it's going to stay exposed to the internet at large. Unless this machine will be a firewall (in which case it pretty much needs to route :-) I'd leave routing disabled - and if someone does hack into it you're still at risk since they can potentially change the configuration and get into the internal network if you have it plugged into an ethernet cable.

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 5294335
Asker : medawson
Subject : From One so-called Expert to another
Private : No

Question : I've been an expert on this site for almost a
year now. I've been wondering if anyone has
reaped any benefits from having joined the site
as an Expert (besides the "there's more happiness
in giving than there is in receiving" rule).

I've asked this of the Experts about a year ago,
and am curious to see if things have changed any
in that span of time.

It's getting kinda difficult to keep up with so
many questions at a time, especially when the
number of people who choose you as a favorite
continues to rise each month (up to 17 now).

I'd look forward to hearing the experiences of
others on this site. Thanks in advance.

Mark E. Dawson, Jr.
Collective Technologies
Senior Unix/Oracle Consultant
http://www.colltech.com

Answer : I've been answering questions on here since Jan or Feb 2000.

The benefits I've reaped (besides winning cash and t-shirts several times) are mostly from knowing I've helped other people with questions they might not have been able to answer otherwise. I like to share what I know with others since I'd be appreciative if they'd do the same for me (I've asked several questions on Askme.com myself). The other benefit is that by answering other people's questions it helps you to stay sharp on the topics that interest you. It also can make an excellent bullet point on a resume for potential employers who can easily see the volume of effort you've put into a voluntary activity helping others over a long period of time. That and for IT folks if they need to verify your technical or writing ability they have reams of evidence (I'm up to 2,324 questions answered) so it's good from that standpoint as well.


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5
Rating : 5


----------------------------------------------------------------------
QAId : 5341090
Asker : divya66
Subject : virtual address
Private : No

Question :
What is a virtual address space ?

Answer : That would likely be a reference to virtual memory or the mapping of hardware locations into the memory map. Virtual memory is the technique of mapping disk space into the RAM memory map to make the system appear to have more RAM that it actually does. This makes the running of more apps (multitasking) feasible on even modeest hardware. As for the hardware device mapping connotation:

When data is being sent to a hardware device like a sound card the system actually routes that data to an address in the main memory map. The sound card's I/O (Input/Output) address was mapped into the system's memory range just before boot-time and any data directed at that area of memory is actually being delivered to the sound card.


Paul Doherty
http://members.home.net/iqueue
Rating : 5


----------------------------------------------------------------------
QAId : 5341149
Asker : divya66
Subject : hard/soft links
Private : Yes

Question :
what do we mean by saying Hard link and Soft link
( file system in unix) ?

Answer : The filing system uses a construct called an "inode" to keep information about the file, including ownership rights and location on the storage device.

A hard link is when you make a new name for an existing file that points to the same location on disk as the original hard link (a hard link is automatically made when you create a file). They both point to the same exact file so when you make a change to one of them they both get changed. If you delete one of the hard links (the new one or the original one) the file is still accessible by the other and the file doesn't actually go away until all hard links are removed.

For example to make a hard link of your /etc/hosts file:

cd /etc
ls -l hosts
(note the number at the left (should be a 1) that indicates the number of hard links this file has)

ln /etc/hosts ./hosts2

Now do another ls -l hosts and note that the number has changed.


A soft link is different. It too represents the file you point it at, but instead it is a separate file that is a redirector. Anyone who comes looking for the symlink name is redirected to the file you linked to. Removing the symlink does not effect the original file.

To create a symlink of /etc/hosts:

cd /tmp
ln -s /etc/hosts ./myhosts

Now if you:

vi /tmp/myhosts

you will be editing the /etc/hosts file since you get redirected to it.

--
Paul Doherty
http://members.home.net/iqueue
Home of DOS/Windows Utilities


P.S.
Please do not ask questions in private if they are not of a private nature. This is a general question, and not of an embarrassing nature. Marking it as private detracts from the value of our interaction to others as they cannot read it under any circumstance.

Rating : 5


----------------------------------------------------------------------
QAId : 5398013
Asker : a2rowe
Subject : unix
Private : No

Question : Hi,
i would like a unix script that greps for a process and if the process does not exist to email me. I have a script that will email me. so basicly i think i need an if else statement i think.

if the grep returns null (no result) do nothing

else
run email script

my programming i pretty weak

can you please help
many thanks

Answer : Ok here's what to do if the process you're looking for is called "stuff":

#!/usr/bin/ksh

ps -ef | grep " stuff" > /tmp/tmpout
if [ ! -s /tmp/tmpout ] ;
then
# we didn't find the process so send email here ;
endif


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



FUQuestion : hi,
thanks for your quick responce.
i get an error message!

script
#!/sbin/sh

ps -ef | grep "wget" > /home/user/tmpout
if [ ! -s /home/user/tmpout ] ;
then
# we didn't find the process so send email here ;
ps -ef | grep wget | /opt/bin/pmail.pl -s 'wget' bob@bob.com
endif

using ksh shell
./grepwget[4]: syntax error at line 5 : `then' unmatched
using sh shell
./script: syntax error at line 9: `end of file' unexpected

can you please help?


Answer : First thing is you didn't use ksh like I did - you included the line:

#!/sbin/sh

instead of mine:

#!/usr/bin/ksh

You don't need to change shells to run the script - just change the line above and run it (using the path to your ksh or sh binary) - it will invoke the shell to interpet the script (that's what the first line is for).

You also need a semicolon (;) like mine at the end of your emailing line. You also need one after the "endif" which I neglected to add.


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 3


----------------------------------------------------------------------
QAId : 5509521
Asker : cindy_lens
Subject : mail
Private : No

Question : On Solaris, I entered this command "mail cindy@localhome.com < "filename"
It works ok. Now, I would like to enter a subject when mailing this file, but cannot figure out how.

Thank you, Cindy

Answer : mailx -s "Check this out!" email@home.com < /wherever/filename

Paul Doherty, CNE, MCP+I, MCSE, CCSA, CCSE
http://members.home.net/iqueue
Home of DOS/Windows Free Utilities
Rating : 5


----------------------------------------------------------------------
QAId : 5567551
Asker : salihasheriff
Subject : UNIX - AIX
Private : No

Question : In Unix - Vi editor how to move the cursor from end of the line to begining of the line. What is the command to be used?

Thanks in advance

Answer : Press "0" (zero) to move to the beginning of a line, and "$" to move to the end.


--
Paul Doherty
http://members.home.net/iqueue
Home of PC DiskMaster and other Windows utilities

Rating : 5


----------------------------------------------------------------------
QAId : 5653928
Asker : abdulq
Subject : Unix - Sun. Redirecting Output both to Screen and File
Private : No

Question : Hi,

How can I redirect output of commands or scripts both to screen and file? For future record, I like to redirect output to Files but then I cannot see the results till the execution of scripts is complete. Is there a way I can do both. Examples:

1) ./run_script > ./logs/script.log
2) tar -tvf /dev/rmt/0 > ./tar_list.txt
3) tar -cvf /dev/rmt/0 /u01 /export/home
1> ./tar_output 2> ./tar_error

I am using Sun Solaris 2.5.1

Answer : Try the "tee" command. It will send the output along as well as redirect it to a file.


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 5685813
Asker : amit_kapila
Subject : how do I write a korn script to ftp files from one server to another
Private : No

Question : how do I write a korn script to ftp files from one server to another

Answer : Here is an example of a ksh script to do just that:

#!/usr/bin/ksh

# for auto FTP to work you will need a chmod 600 file in the originating user's dir
# with the following line (.netrc file):
# machine mymachine.wherever.com login myusername password mypassword

ftp mymachine.wherever.com 1>/dev/null <<!EOF
bin
lcd /var/log/
cd log
put myfile.tar.gz
bye
!EOF


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 3.9
Rating : 3.9


----------------------------------------------------------------------
QAId : 5685826
Asker : salihasheriff
Subject : UNIX - AIX
Private : No

Question : Can I install UNIX/Linux in my PC which has already dual operations system ie., Windows 98 and Windows NT 4.0

Please suggest me.

Thanks in advance

Answer : I'm not sure where AIX comes into this, but yes you should have no trouble with adding Linux after-the-fact. It will replace the MBR with it's own and offer you a choice on booting - if you choose 'Windows' it will then offer you the same menu you're getting now (where you choose between NT and 98).


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 4.6
Rating : 4.6


----------------------------------------------------------------------
QAId : 5729300
Asker : petemcevoy
Subject : pop3 account setup
Private : No

Question : Hi,
I need to set up quite a few accounts on my hosts pop3 server, unfortunately their web front end is pitifully slow and it would take me far too long long to administer them all from there.I was wondering if I could telnet to port 110 of the server, login and add the accounts myself from the command line, if this is possible could you tell me the commands i would need (the only ones i know at the moment are user,pass and dele!!) or point me to a resource on the web where i could find this information.
Thanks for your time

Answer : I don't believe the POP3 standard interface will offer the ability to create accounts. It will likely only allow manipulation of the accounts (and their mail) that already exist.

http://pages.prodigy.net/michael_santovec/pop3telnet.htm


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 5745779
Asker : collinl
Subject : UNIX: Protect Dir from World
Private : No

Question : I have some data files in a directory on my Web server that I want to prevent the public from viewing. However, that directory needs to be accesses by other CGI scripts on my server. Is there any way to do that? Will chown and chgrp do the trick? If yes, how? Thanks!

Answer : I would try making the user that owns the www/CGI processes the owner of that subdirectory tree, and limit access to only that user. If the directory was /usr/www

cd /usr/www
chown www:www .
chown -R www:www ./*

(assumes you have a 'www' user and group)

Then you would want to change the permissions of the files:

chmod go-rwx .
chmod -R go-rwx ./*


Now try an 'ls -al' from there and make sure all the rights are revoked for group and other.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities


Rating : 4


----------------------------------------------------------------------
QAId : 5751095
Asker : kalrapuneet
Subject : Shell Programming
Private : Yes

Question : Hi,
I have to write a shell program to display an employee's information for a company. A part of my program is to count and display the number of working hours in any given month of a year 2001. I am really stuck in this part. I would be very grateful if you could help me.

Thanx,
P K

Answer : Here are a bunch of discussions about the topic. Click each you want to see and then click "View complete thread" at the top-right to see all of the messages in that thread.


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 5882936
Asker : hgil21
Subject : unix
Private : No

Question : hi how are you ??

I work as a junior sys adm. and
I am on a project to write a shell script "to copy raw devices from one server to other server". Can you give me conceptual idea to begin with.

Need More Information : Do you mean backup a raw device? Or do you mean create the same raw devices on another machine?

FUQuestion : to copy raw devices from one machine ( production) to another ( some applications). They need it so they can have another machine for users to decrease the load on production machine.

Answer : Look into the 'mknod' utility. Most of these devices are created automatically by the system, I believe, but I think it would be the app involved if you needed to make one manually.


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 5894564
Asker : Anonymous
Subject : Unix & smart calculator
Private : Yes

Question : The following are the script for a smart calculator. I've tried to compile, but it didn't run. Pls help me to correct the script!



echo "Enter a number: \c"
read num1
echo "Enter another number: \c"
read num2
echo "Enter an operator (+,-,/,*,%): \c"
read oper
if [ $oper = + ]
then x = 0
x = `expr $num1 + $num2`
echo "The output is: \c" $x
elif [ $oper = - ]
then x = 0
x = `expr $num1 - $num2`
echo "The output is: \c" $x
elif [ $oper = / ]
then x = 0
x = `expr $num1 \/ $num2`
echo "The output is: \c" $x
elif [ $oper = * ]
then x = 0
x = `expr $num1 \* $num2`
echo "The output is: \c" $x
elif [ $oper = % ]
then x = 0
x = `expr $num1 \% $num2`
echo "The output is: \c" $x
else
echo "invalid input!"
fi

Answer : OK here you go:

#!/usr/bin/ksh
echo "Enter a number: \c"
read num1
echo "Enter an operator (+,-,/,*,%): \c"
read oper
echo "Enter another number: \c"
read num2
if [ $oper = + ]
then
x=`expr $num1 + $num2`
echo "$num1 $oper $num2 = $x"
elif [ $oper = - ]
then
x=`expr $num1 - $num2`
echo "$num1 $oper $num2 = $x"
elif [ $oper = / ]
then
x=`expr $num1 \/ $num2`
echo "$num1 $oper $num2 = $x"
elif [ $oper = * ]
then
x=`expr $num1 \* $num2`
echo "$num1 $oper $num2 = $x"
elif [ $oper = % ]
then
x=`expr $num1 \% $num2`
echo "$num1 $oper $num2 = $x"
else
echo "invalid input!"
fi


The only thing this doesn't work on is the multiplication. I think the asterisk gives it fits and may need to be escaped or handled in some other way.


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 5937848
Asker : Anonymous
Subject : Unix Bourne Shell programming
Private : Yes

Question : I need to develop a program which accepts a number which is non-zero and not greater than the number of files in the current directory. The program should then display the file name, permissions and size for that file number (in that order). If there are 10 files in the directory and the number entered is 6, the program should display the specified details for the 6th file.

Could U please correct my script?! Thanks!

Here's my script:

#!/bin/sh

ls -1|sort
totalfile=`ls -1|wc -w`
echo "there is $totalfile file(s) in `pwd` directory"
echo "Please enter filaname number : \c"
read fnumber

if [ $fnumber -eq 0 -o $fnumber -gt $totalfile" ]
then
echo "The number you enter is larger than $totalfile or zero"
exit 1
fi

fnumber=`expr $fnumber + 1`
temp=`ls -l|sed -n "$fnumber" 'p'`
filename=`echo $temp|awk '{print $9}'`
permission=`echo $temp|awk '{print $1}'`
size=`echo $temp|awk '{print $5}'`
echo "Filename : $filename "
echo "Access permission : $permission"
echo "File size (in bytes) : $size"


Answer : Here you go:

#!/usr/bin/ksh
ls -1|sort
totalfile=`ls -1|wc -w`
echo "there is $totalfile file(s) in `pwd` directory"
echo "Please enter filaname number : \c"
read fnumber

if [ $fnumber -eq 0 -o $fnumber -gt $totalfile ]
then
echo "The number you enter is larger than $totalfile or zero"
exit 1
fi

temp=`ls -1|sed -n "$fnumber"'p'`
echo VALUE of temp is $temp
filename=`ls $temp`
permission=`ls -l $temp | awk '{print $1}'`
size=`ls -l $temp|awk '{print $5}'`
echo "Filename : $filename "
echo "Access permission : $permission"
echo "File size (in bytes) : $size"


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 5951294
Asker : hive42
Subject : chmod
Private : No

Question : i am trying to figure out how touse chmod to change permissions of an executable so it is actually executable by me

i am the owner and i would like read write and execute acess to my file

i have tried reading the man pages but i can't quite figure out what flags to use and how to pass it the file name

any examples would be most helpful

thanks

Laura

Answer : Just type:

chmod u+x file

to give yourself ("user" who is the owner of the file listed in an 'ls -l' command) execute permission. To change other attributes:

chmod u-w file

would remove write permission for the user (owner) from 'file'.

chmod ug+rx

would add read and execute permissions for user and group (group owner listed in an 'ls -l' command).

The numeric method mentioned by another expert is what I usually use. It's very easy:

R W X
4 2 1

A "read" permission is worth 4 points
A "write" permission is worth 2 points
An "execute" permission is worth 1 point

So to change the permissions of any file to be what you want give the permissions you want and add the numbers up for the permissions you chose. For example:

I want to give the owner of the file full access, the group owner read and execute permissions only, and "other" no permissions at all ("other", BTW, simply means anyone who is not the actual owner of the file (user) or a member of the group that shares ownership (group)).

Since I want full permissions for owner the first number will be all rights added together:

user:
R + W + X
4 + 2 + 1 = 7

So we'll use a 7 in the first position for the owner's rights.

Now we want read and execute for the group owner:

group:
R + X
4 + 1 = 5

So we'll use a 5 in the second position for the group's rights.

Finally we want no rights for other:

other:

no rights = 0

So our chmod command is simply this:

chmod 750 file

which gives our user full rights, our group read and execute, and grants "other" no rights at all.


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities




Rating : 5
Rating : 5


----------------------------------------------------------------------
QAId : 5951310
Asker : Anonymous
Subject : How can i know the size of a directory in Sun Solaris 7 ?
Private : No

Question : How can i know the size of a directory in megabyts under Sun Solaris 7 ?

thank you for your time ?

Answer : I always just cd into the directory to check and do a:

du -k

The total at the bottom is the total amount (in K) that the directory is using.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities




----------------------------------------------------------------------
QAId : 6007084
Asker : a2rowe
Subject : unix
Private : No

Question : hi,

is there a command in unix to delete the first file lines in a file with out using a text editor?

many thanks

Answer : You can do it like this:

cat file | tail +4l >> newfile
mv newfile file

The above would create a new file called 'newfile' that contains all the lines except the first four from 'file'. The second line copies it back over the original.


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 4.9
Rating : 4.9


----------------------------------------------------------------------
QAId : 6134949
Asker : peichun28
Subject : "cat" command
Private : No

Question : Hi! I face the problem and hope can get some assist from your.
Currently, my working environment have 2 Sun Server :

Assume :
Svr1 - IP Address : 199.1.1.1
Svr2 - IP Address : 199.1.1.2

At Svr1 : I have one file call file1
At Svr2 : I have one file call file2

Now, at Svr1 I need to combine the file1 (Svr1) and file2 (Svr2)

Last time the file is at same server so I just have to use the “cat” command then solved the problem ?
But now the file is at different server so is there any methods can combine this two file ? (beside FTP over the file from Svr2)

Can the "cat" command combine two file from different server ?

Thanks !

Answer : If you have ssh installed (comes with ssh, scp, and slogin commands - usually stored at /usr/local/bin) you can try it this way:

on Svr1:

echo `ssh svr2-ip-address:cat /whereever/file2` >> file1

Those are backticks (`) above.


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6134981
Asker : peichun28
Subject : "cat" command
Private : No

Question : Hi! I face the problem and hope can get some assist from your.
Currently, my working environment have 2 Sun Server :

Assume :
Svr1 - IP Address : 199.1.1.1
Svr2 - IP Address : 199.1.1.2

At Svr1 : I have one file call file1
At Svr2 : I have one file call file2

Now, at Svr1 I need to combine the file1 (Svr1) and file2 (Svr2)

Last time the file is at same server so I just have to use the “cat” command then solved the problem ?
But now the file is at different server so is there any methods can combine this two file ? (beside FTP over the file from Svr2)

Can the "cat" command combine two file from different server ?

Thanks !

Answer : If you have ssh installed (comes with ssh, slogin, and scp commands) you can try something like this:

Executed on Svr1:

echo `ssh Svr2_IP_Address:cat /whereever/file2` >> file1

This will use ssh (secure shell) to execute a cat command inside the backtick quotes on the remote system. The cat command will spit the contents of file2 and return it to file1 from standard input (STDIN). The echo command will then send that output in a concatenate command (>>) and add it to the end of file1. In the end file1 should contain the contents of file1, followed by file2.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 4


----------------------------------------------------------------------
QAId : 6180933
Asker : dan.burke@...
Subject : What to know?
Private : No

Question : I am currently in the US air force as a Unix Admin SV4. But on our end we are just endpoint admins. I do weekly backups, add/del new users & look over Security/GW status reports for the system, and also installed a stand alone Solaris 8 machine that I mess around with, but we don't have full controll of the system. I'm more like a Unix Database Admin. I also work with Oracle HR & NT machines, but they also are limited access to the whole system. When it comes to going for an interview I have no idea what kind of questions will come up & do I actually have the whole experience to be a Unix Admin on the outside by not dealing with the whole system?
Basically, what are important factors & knowledge that employers look for in a Unix admin, and what could I do or study in the next year to be ready? Thanks.
DAN

Answer : It's kind of hard to say - you need to be able to think in the UNIX mindset, so to speak. Once you can think that way (understand the differences between, say, Windows and UNIX) then here are some other items of importance:

UNIX commands (ls, cp, cat, tar, etc...)
startup/shutdown scripts
backup/restore
disk layout/partitioning/mirroring/RAID
programming (scripts/Perl)
hardware additions (how to add/remove)
mounting devices (CD-ROM, floppy)
configuring the user environment - login scripts (.profile), environment variables, etc
creating/removing accounts (useradd, etc)
changing passwords
permissions and how to modify (chown/chgrp/chmod)

Those are some of the important things I can think of off the top of my head. Starting with these will certainly lead to some more.

Best of luck!

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6222656
Asker : subirp
Subject : Copying Dire. from CDROM
Private : No

Question : Hi,
As root, I copied using "cp -p -R /SD_CDROM /cd2"
the entire directory structure from a CD (/SD_CDROM is the CD mounted file system) in Hp-ux
to another filesystem (/cd2)on the same server.

My question:
How come when I do a du -ks on one of the sub
dire. in separate file systems they reveal diff. size (I was expecting everything the same)? Am i missing a file or two ?

How come no. (ex. below revealed
1024 for one direc. and 4096 for another.) ?
And what are these numbers. ? Dir. Size ?
========================

# pwd
/cd2/SD_CDROM/stage/Components
# ls -l
dr-xr-xr-x 2 25882 502 1024 Sep 22 2000 DataFiles

# du -ks DataFiles
10628 DataFiles

=======================================

# pwd
/SD_CDROM/stage/Components
dr-xr-xr-x 2 25882 502 4096 Sep 22 2000 DataFiles

# du -ks DataFiles
10631 DataFiles

Answer : You are likely seeing the difference in allocation units per device. This is the cause of what is commonly referred to as "slack space". Every device that can store data has a smallest addressable element it can write data to, similar to an atom (or quark) being the smallest unit of matter. No file can be smaller than this smallest unit unless compression is involved (where a file spans multiple units). So all you are seeing is that in one case the cluster size is 1K (1024 bytes) and in the other it's 4K (4096 bytes).

To ensure you got all the files you can redirect the output from a find to files and then diff them:

cd /cd2
find . > /tmp/a

cd /SD_CDROM
find . > /tmp/b

cd /tmp
diff a b > c

more c

OR you could count the files and dirs using this type of construct:

cd /cd2
find . | wc -l

cd /SD_CDROM
find . | wc -l

and ensure the count was the same.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 6228507
Asker : aserebry
Subject : bcp
Private : No

Question : What is comand 'bcp' stand for, what it does and what is the basic syntax of using this command.

thanks in advance!

Answer : It's the "bulk copy command" and appears to be a Sybase utility.

The syntax is here:

http://manuals.sybase.com/onlinebooks/group-as/asg1250e/util/@Generic__BookTextView/3467

(click the small "bcp" link at the top for the exhaustive syntax)


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 6304446
Asker : hpchua
Subject : Solaris 7 Sys Admin Test Guide
Private : No

Question : Hi folks,

Has anyone of you guys have a study guide for Solaris 7 System Administartion, Volume I? Can I have a question and answer for you guys who had been seated for Solaris 7 System Admin I (310-009) test? Now, I'm trying to get as many question as possible so that I have enough practises before seat for the exam.

Thanks in advanced!

Answer : Try these exam cram study sheets:

http://cramsession.brainbuzz.com/cramsession/Sun/

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 4


----------------------------------------------------------------------
QAId : 6304495
Asker : Anonymous
Subject : Solaris naming services
Private : No

Question : What is and where is or how do i find the file that Solaris uses to determine what naming services it should use?

Answer : There are two files you need:

/etc/nsswitch.conf

and

/etc/resolv.conf


In nsswitch.conf you will have something similar to this:

#
# /etc/nsswitch.files:
#
# An example file that could be copied over to /etc/nsswitch.conf; it
# does not use any naming service.
#
# "hosts:" and "services:" in this file are used only if the
# /etc/netconfig file has a "-" for nametoaddr_libs of "inet" transports.

passwd: files
group: files
hosts: files dns
ipnodes: files
networks: files
protocols: files
rpc: files
ethers: files
netmasks: files
bootparams: files
publickey: files

(lines truncated)

The important line to note is the one for "hosts:" - that is the line that determines what services, and in what order, should be consulted to resolve hostnames. It should be set to "files dns" as above unless you're using NIS.

The resolv.conf file will appear similar to this:

domain myco.com
nameserver 15.19.9.20
nameserver 15.19.9.21
search myco.com

Here you put your local DNS domain you reside in, the IPs of each DNS server you need, and the search domain(s) you want truncated to bare hostnames when performing a search for resolution (keeps you from having to type mywebserver.myco.com - you can just type mywebserver and it will append if needed).

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6304508
Asker : mshetty224
Subject : Read a string from output stream
Private : No

Question : Hi,

We are trying to read a string ("Password") output by a utility using Java on Unix. Reading the output stream returns a -1.

Thanks and Regards,
Mranalini

Answer : Try reading both STDOUT *and* STDERR. You may only be getting STDOUT and the utility may only send a return code there.

javautil 1>/tmp/a 2>&1

This (if using sh or ksh) will send the output of both to a file called /tmp/a.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 4


----------------------------------------------------------------------
QAId : 6368751
Asker : sanjay_bhatia
Subject : problem with unix
Private : No

Question : I got a assignment from my university, if someone can help me out to get the real answer for the whole assignment for free, would be really appreciated but if someone has to spend special time then please let me know that how much you will charge for it.

*********************************************

Please go to the link below:

http://www.infocom.cqu.edu.au/Courses/win2001/COIT13146/Assessment/Assignment_%31/


I would really appreciate your help in this matter


Answer : Perhaps you should read the assignment, particularly the section on plagiarism, and then solve the problem on your own? Certainly the course that preceded this test prepared you for such a test?
Rating : 1.3
Rating : 1.3


----------------------------------------------------------------------
QAId : 6372171
Asker : MudChell
Subject : Unix Account Management
Private : Yes

Question : I'm writing codes for removing users accounts. But after removing the users accounts, I can still see the user's name in the last column of the group file.


Pls advise how do I remove a user name from a group file? THanks!

*** I'm only testing it under my own account. I'm not the root user.

Answer : The only thing that makes a user a member of a group is his being listed in the file /etc/group - if your user deletion isn't removing them from there then you can remove them manually, but since the account doesn't exist anymore it's not really much of a risk.
Rating : 2


----------------------------------------------------------------------
QAId : 6435337
Asker : MudChell
Subject : Unix statement
Private : No

Question : Pls advise the correct interpreatations of the following Unix statement:

rm -rf ` ls /tmp | sed -e `/^\.$/d -e /^\.\.$/d'`

Answer : It is a garbled sed statement as-is, but it appears to be trying to remove all files from the /tmp directory *except* the "." and ".." directory entries. Here is what it should look like:

rm -rf `ls /tmp | sed -e '/^\.$/d' -e '/^\.\.$/d'`

The first part of the sed statement:

-e '/^\.$/d'

will look for lines that begin(^) with a period (\.) and are followed by nothing up to the end of the line($). It will then delete(/d) those lines.

The second part of the sed statement:

-e '/^\.\.$/d'

performs a second edit command and does the same as the first, except it looks for two periods and and end-of-line (EOL).

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities


Rating : 3


----------------------------------------------------------------------
QAId : 6454046
Asker : vlinda2000
Subject : NFS maestro
Private : No

Question : IN Windows Explorer of Windows 2000, when I copy a folder from Windows 2000 to a folder on a Solaris machine using NFS Maestro, the permission always are chmod 700 for the folder and all the files and subfolders under this folder also has chmod 700. I would like it to chmod 755 automatically on every files and folders. Do I set this auto chmod somewhere in NFS Maestro of Windows 2000 or on the Solaris machine?

Many thanks
Linda

Answer : I'm not that familiar with NFS Maestro, but I would bet your problem is with a umask setting (either in Maestro, or on the UNIX machine you're copying files to). Try to find where the default umask for copied files gets set within Maestro or examine the umask setting on the UNIX machine (on my Solaris machine it is set as 022 within /etc/profile).

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6554018
Asker : slimshady74
Subject : UNIX
Private : No

Question : I would really like to start learning unix but I don't know where to start. I mean is unix free and if it is from where can I download it and some tutorials to get me started.

Answer : The easiest way to gain experience with a PC is to get a copy of Linux. You can get one from here:

ftp.linuxberg.com

cd into /pub/ISO and you will find ISO (CD) images of many Linux distributions. I suggest Mandrake as it is excellent. Once you get the ISO file you can use Easy CD Creator or another CD burning program to make a CD from it.

Then for assistance with Linux try this web site:

http://www.linuxnewbie.org

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities





----------------------------------------------------------------------
QAId : 6609898
Asker : mha_a
Subject : Permission denied
Private : No

Question : hi

I tried to delete a directory
rm -r *

but it comes this output
man1/a2p.1: override protection 555 (yes/no)? y
man1/a2p.1 not removed: Permission denied

but i am sure i am the owner for this directory.
Is there a way to force deleting such directory??

Answer : Have you tried

rm -Rf dirname
Rating : 5


----------------------------------------------------------------------
QAId : 6610380
Asker : aserebry
Subject : IP address
Private : No

Question : Hi,

I need to find out an IP address on the UNIX server. How can I do that?

Thanks!

Answer : Type:

ifconfig -a
Rating : 2

Answer : Try becoming root first... ;-)


----------------------------------------------------------------------
QAId : 6626172
Asker : sanagapalli_2000
Subject : Internet connection problem in Sun Solaris
Private : No

Question : Hi,

I have installed Sun Solaris on intel platform. Can some one help me how to connect to net from Sun Solaris box.

Thanks

Answer : Use "ifconfig -a" to view your interfaces and configure them (man ifconfig for syntax)

Also ensure you have the proper DNS info in:

/etc/nsswitch.conf
/etc/resolv.conf

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 4


----------------------------------------------------------------------
QAId : 6748158
Asker : aserebry
Subject : C Shell
Private : No

Question : Hi,

I'm writing a small app in c shell scrip (.sch extension) Do you know the correct syntax of the while look in c shell.

Thanks!

Answer : I wrote you a small example program to demonstrate it:

#!/usr/bin/csh
# example of a csh while loop
set i=0
echo $i
while (1)
echo $i
set i=`expr $i + 1`
if ($i > 10) break
end

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 6748519
Asker : aserebry
Subject : Syntax in C Shell
Private : No

Question : /home/rndftp/extracts/custstmt/chk_stmt_dt.plset $chkstmtdtret=$?

This is what I'm trying to do in C Shell . First line runs a different script and the second line assins the value returned by the script to the variable. I'm getting an error on the second line: Variable syntax. Can you tell me what is the problem in these two lines accourding to C Shell script syntax rules.

Thanks a lot!

Answer : The problem comes from the fact that the first script is running its own shell command. Then you are launching another and attempting to get the return value from it within the first. One way to do this is to run the second script's commands *inline* with the first. I did it with these test files I wrote; the first is called "test1.csh" and the second is called "returncode.csh"

test1.csh:

#!/usr/bin/csh
set chk=0
echo CHK is $chk
source /export/home/ped/scripts/returncode.csh
echo CHK value is: $chk

returncode.csh:

set chk=27

Notice that I am able to change the value of the variable from the first script by the line in the second, because I use the "source" command to run the contents of the second script within the first, which stops the second invocation of a csh interpreter. The result of a run:

./test1.csh

CHK is 0
CHK value is: 27

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities





----------------------------------------------------------------------
QAId : 6748529
Asker : aserebry
Subject : Syntax in C Shell
Private : No

Question : /home/rndftp/extracts/custstmt/chk_stmt_dt.plset $chkstmtdtret=$?

This is what I'm trying to do in C Shell . First line runs a different script and the second line assins the value returned by the script to the variable. I'm getting an error on the second line: Variable syntax. Can you tell me what is the problem in these two lines accourding to C Shell script syntax rules.

Thanks a lot!

Answer : The problem comes from the fact that the first script is running its own shell command. Then you are launching another and attempting to get the return value from it within the first. One way to do this is to run the second script's commands *inline* with the first. I did it with these test files I wrote; the first is called "test1.csh" and the second is called "returncode.csh"

test1.csh:

#!/usr/bin/csh
set chk=0
echo CHK is $chk
source /export/home/ped/scripts/returncode.csh
echo CHK value is: $chk

returncode.csh:

set chk=27

Notice that I am able to change the value of the variable from the first script by the line in the second, because I use the "source" command to run the contents of the second script within the first, which stops the second invocation of a csh interpreter. The result of a run:

./test1.csh

CHK is 0
CHK value is: 27

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 6758272
Asker : Anonymous
Subject : REMOVING A NETWORK INTERFACE
Private : Yes

Question : I need help with removing a network interface.

OS: Solaris

I know how to install one: ifconfig hme0 plumb

But for some reason, one of my collegues must of added 2 identical ones, because when I do ifconfig -a, I see 2 hme0 interfaces.

I went to /etc and I saw 2 files:

hostname.hme0 and hostname6.hme0

I erased the hostname6.hme0 but it did not remove the network interface.

What command do I use to remove the 2nd hme0 network inferface?

Am I correct in assuming that the present configuration is incorrect as pertaining to having 2 hme0 network interfaces?

Should the next interface be hme1?

Thanks!

Neapolitan

Need More Information : Can you show me the exact output from an

ifconfig -a

FUQuestion : lo0: flags=1000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
hme0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
inet 192.168.5.2 netmask ffffff00 broadcast 192.168.5.255
lo0: flags=2000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6> mtu 8252 index 1
inet6 ::1/128
hme0: flags=2000841<UP,RUNNING,MULTICAST,IPv6> mtu 1500 index 2
inet6 fe80::a00:20ff:feff:ddbf/10
hme1: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 3
inet 10.0.0.30 netmask ffffff00 broadcast 10.0.0.255

Answer : You don't have two hme0 interfaces, you have the hme0 interface loaded with BOTH ipv4 and ipv6 (next-generation) protocols. The IPv6 is the new longer internet addresses. If you're not using it you can remove it or leave it - it's not hurting anything.

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 3
End :


----------------------------------------------------------------------
QAId : 6791522
Asker : Anonymous
Subject : Sharing A Folder
Private : Yes

Question : I have Samba installed so I can view my Unix machine in Windows 2000.

I see that I have a shared folder that I can mapped to. When I do ls -la, the folder looks like this:

web -> /home/httpd/html/

What does this mean?

How can I share a folder? What command do I use? Alos, what does the /home/httpd/html/ mean and how can I use it to my advantage?

Thanks!

Neapolitan

Answer : Samba makes UNIX machines speak the same networking language as Windows machines.

You will need to add the paths you want to share on the UNIX machine to your smb.conf file (should be in /etc) similar to this:

[public]
comment = Public Stuff
path = /home/public
public = yes
writable = yes
printable = no


More docs on the smb.conf file are here:

http://www.linuxdoc.org/HOWTO/SMB-HOWTO-6.html

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities



Rating : 5
End :


----------------------------------------------------------------------
QAId : 6840502
Asker : Anonymous
Subject : newbie: Installing Patches from CD Rom
Private : No

Question : Hi,

I've been given a Sunsolve CD rom (version 5.0.3)
and told to download the latest patches.

I'm new to Solaris so could someone outline the
steps needed after I physicaly mount the CD rom.

Thanks

Answer : Just run (as root)

patchadd -d .

in the directory with the patch.

If you got all the "recommended" patches in a group and extracted them all into a directory it may look like this:

[ped@]newton] /export/home/ped/8_Recommended $ ls
108434-03 109238-02 110322-01 111071-01
108435-03 109277-02 110380-03 111090-03
108528-11 109279-18 110383-02 111098-01
108652-40 109318-20 110387-03 111111-01
108725-05 109320-04 110390-02 111177-06
108727-09 109322-08 110453-01 111232-01
108827-12 109324-02 110458-02 111234-01
108869-10 109326-06 110460-09 111293-04
108875-09 109470-02 110615-01 111310-01
108968-05 109657-05 110662-04 111325-01
108974-14 109667-04 110668-01 111327-04
108975-05 109742-04 110670-01 111504-01
108977-01 109783-01 110700-01 111548-01
108981-07 109805-04 110723-03 111570-01
108985-03 109882-04 110898-02 111596-02
108987-07 109885-05 110901-01 111606-02
108989-02 109888-12 110903-02 111659-02
108991-17 109898-05 110916-02 111826-01
108993-04 109904-05 110934-04 111874-02
108997-03 109906-06 110939-01 111881-01
109007-06 109951-01 110943-01 CLUSTER_README
109091-04 110075-01 110945-03 copyright
109147-12 110283-04 110951-01 install_cluster
109181-04 110286-03 111069-01 patch_order

Note the extra files included, one of which is a script called "install_cluster" which will handle running patchadd for you. You can just run it as ./install_cluster


--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities


Rating : 3
End :


----------------------------------------------------------------------
QAId : 6913656
Asker : demund_98
Subject : xwd command
Private : No

Question : i've got 2 unix connected together. How can i use the xwd (X Window dump) command to dump the screen of another machine through a remote login?
I must use remote login cos the machine is running some application and the only way to "print screen" is to remote login and perform xwd. though i know the syntax of xwd, it does not seem to work.

can you give me an example assuming that i want to "print screen" from a unix named "Tomato" and output to a file named "Tomato"? this is assuming that i will rlogin from another unix.

I have no problem doing xwd on a unix, but has problem doing xwd on ANOTHER unix.

Thanks

Answer : Since you didn't show the syntax you're using, or what UNIX this is I'll display what the command would look like:

xwd -display tomato_ip_or_dns_name:0 -root | xwud

Or

xwd -root -display tomato:0 | xwud -display pumpkin:0


will open a window on your machine, pumpkin, containing the image currently displayed on tomato:0. You must have access rights to both displays.

Or you can do it like this:

xwd -display:tomato filename

which should give you an image 'filename' viewable in xview.

Also look into VNC which will allow real-time remote control:

http://www.uk.research.att.com/vnc/

--
Paul Doherty
http://members.home.net/iqueue
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 6996130
Asker : bottaxxgp25
Subject : Copy files from unix
Private : No

Question : Hi from italy.

I'm not very skilled in UNIX.

Can i copy with the command cp all the file with a creation date greater of a specified date?

Thanks for all.

Gian Paolo from Milan.

Answer : To do this you will need a file that has a date of creation/access the same as the cutoff date and time you want to use. To create a fil just issue a command like this:

touch -t 12021630 /tmp/stuff

This will create a file "/tmp/stuff" that will show a creation/access date of Dec 02 of the current year (several days ago). You then can use that file to perform the search and copy for files newer than that with this:

cd /wherever/your/files/are
find . -newer /tmp/stuff -type f -exec cp {} /wherever \;

"-newer /tmp/stuff" indicates you only want files newer than the date of the file you just created.

The "-type f" will ensure that only files are copied and not directories.

The "-exec cp {} /wherever" will copy each found item to /wherever.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Answer : Don't forget to rate the answers you receive on AskMe.com... thanks!


----------------------------------------------------------------------
QAId : 7012343
Asker : probin
Subject : Learning UNIX
Private : No

Question : I want to learn UNIX quick. I have a system running Windows 98 with two partitions C and D. 1. What is the best way to install UNIX on these machines.
2. Which UNIX will be suitable for learning purposes?
3. Can I download UNIX systems from Internet using Windows computer and then copy those files to some other system for installation?

Please help.

Answer : Since most of us don't have the expensive antive UNIX systems that run Solaris, or AIX at home, Linux is a good alternative to get familiar with a UNIX system since it's so similar.

Get the ISO images for free at the site below. Just burn them to CDs and install to any system you like.

http://www.linuxiso.org

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 3


----------------------------------------------------------------------
QAId : 7013437
Asker : sls5012
Subject : commands for creating users & their accounts
Private : Yes

Question : Hello Paul,

I am learning Unix now. I have installed Unix2.6, but just can't get any graphics like admintool. At the # prompt, I type: admintool, I got:
# can't open display
Could you tell me how can I get these graphics?
What's the commands for add users and their accounts without using admintool graphic?

Thanks in advance,

Linda
sls5012@yahoo.com

Answer : To get admintool to work (I'm assuming you're in Solaris and running CDE (the graphic interface) you'll need to set the DISPLAY environment variable - type:

ksh
DISPLAY=X.X.X.X:0
export DISPLAY

where X.X.X.X is your IP address - get it with:

ifconfig -a

As for creating users from the commandline:

useradd -d /export/home/newuser -m -k /etc/skel -s /usr/bin/ksh newuser

then create a password:

passwd newuser

Also, please refrain from asking questions as private - this is not an embarrasing or private question and you reduce the value of our interaction by setting the question as private. No one else can read it.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 5

FUQuestion : Hi Paul,

I will not ask quiestion as private again.
I have successfuly added users and password. But I can not get the graphic displaied. I got the same message: cann't open dispaly.

Thanks very much,

Linda

Answer : Try it as:

DISPLAY=X.X.X.X:0.0
export DISPLAY

or

export DISPLAY=X.X.X.X:0.0

I left off the ".0" in the first example I gave you.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 7034260
Asker : sls5012
Subject : how to exit "ed" tool
Private : No

Question : Hi Paul,

Thanks for your previous answer.
In Unix 2.6, I used ed command to edit my files. How can I exit this edit tool?
e.g. $ ed my_file
1,$p
/ .../
" how can I exit the ed command?"
Thanks in advance,

Linda

Answer : Just type q by itself and hit enter.

Rating : 5


----------------------------------------------------------------------
QAId : 7042853
Asker : sls5012
Subject : what is the diff between HP-Unix & Unix
Private : No

Question : Hello,

What are the difference between HP-Unix and Unix?
I am searching a position now. I found one company requires experience in HP-Unix/Oracle SQL.
So I want to know the difference of HP-Unix and Unix.

Thanks in advance,

Linda

Answer : UNIX is a general term that encompasses all UNIX systems. It describes in the most general terms what it is to be UNIX> HP UNIX, Solaris (Sun), AIX (IBM), and all others are variants of UNIX and will share many similarities. They will also have many peculiarities and proprietary items where they will differ. So when someone says they want HP-UX UNIX they mean they want someone who knows that flavor of UNIX.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4


----------------------------------------------------------------------
QAId : 7094864
Asker : sls5012
Subject : Variables
Private : No

Question : Hello,

I try to store a value inside a shell variable. What I did:
witch% count=1

I got:
count=1: command not found

Could you tell me how can I store a value inside a shell variable?

Thanks in advance,

Linda

Answer : Your problem stems from the fact you're using the C shell (csh). You can do it this way in csh:

set count=1
echo $count


In sh (Bourne), ksh (Korn) or bash (Bourne Again) you can do it like this:

ksh (to get to a Korn shell)
count=1
echo $count

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 5

FUQuestion : Hi Paul,

1. How can I remove these variables? If these variables are not removed, will they take some memory?

2. How can I change to sh (Bourne), ksh (Korn) or bash (Bourne Again) shell?

Thanks in advance,

Linda

Answer : As I mentioned above just type in the name of the shell you want from the shell you're in to invoke a new shell of that type. So if you're currently in csh (C shell) and want a Korn (ksh) shell just type:

ksh

and you'll be in a Korn shell and can do the things you want. You can then "logout" and you'll be back in the csh shell.

If you decide you like one shell over another you can change your default shell with the chsh (not available in all systems) or you can edit the file:

/etc/passwd

and change the shell entry at the end of the line that has your entry with the shell you want - for example your entry may look like this:

myacct:x:108:1::/export/home/myacct:/usr/bin/csh

You change the line to be like this to get Korn
shell as your default:

myacct:x:108:1::/export/home/myacct:/usr/bin/ksh

Be aware that sh/ksh use different files (they use .profile in your home directory) for initializing your session so you may need to migrate any PATH or other settings to the .profile in order to maintain those settings. If you get good results typing ksh at a prompt (not missing PATH info or anything) it's probably fine to switch on over to ksh in the /etc/passwd (plus you can always switch back).

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities






----------------------------------------------------------------------
QAId : 7128801
Asker : thd1811
Subject : tar with the p option
Private : No

Question : When I do a tar I want to preserve the date and file permissions so I use the p option. I was wondering where I would put the p in a command like this:

tar cfp - <dir>|(cd <dir2> ; tar xfp -)

Do I need to put the p twice??

thanks,


Answer : tar -cvpf - <dir> | (cd <dir2> ; tar -xvf -)

The "f" parameter needs to immediately precede the location and that is why yours is failing.

FUQuestion : Is that true with Solaris systems too? It seems to work without having the f option preceding the location, the thing I was wondering is if I need to specify the p option twice. thanks!


Answer : I don't believe the 'p' applies to extracting the files. 'p' preserves the permissions during archiving and is the default during extraction with 'x', per the man page:

"p Restore the named files to their original modes, and
ACLs if applicable, ignoring the present umask(1).
This is the default behavior if invoked as super-user
with the x function letter specified. If super-user,
SETUID and sticky information are also extracted, and
files are restored with their original owners and per-
missions, rather than owned by root. When this func-
tion modifier is used with the c function, ACLs are
created in the tarfile along with other information.
Errors will occur when a tarfile with ACLs is
extracted by previous versions of tar."

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities


Rating : 5


----------------------------------------------------------------------
QAId : 7131982
Asker : Terrtorr
Subject : General question
Private : No

Question : Which is better MCSE & RHCE or a BA in Computer Sceince.

Answer : That depends on whether you'd like to have a career in IT (BA) or be an IT wage-slave your whole life, relegated to technical jobs (MCSE/RHCE).

I hate to sound so sarcastic but I get sick of people trying to equate 4 full years of study and sacrifice to certifications that can be achieved in 6 months of part-time study. They are not even close to the same thing.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4


----------------------------------------------------------------------
QAId : 7143713
Asker : piyux
Subject : How to trigger a script after to receive a file from a remote host?
Private : No

Question : Hi guys, I'll appreciate your help with the following problem.
I'm using remote shared folders (nfs server/client) to move information from several remote hosts (sun and linux) to a central host (linux). After to receive a file I need to do something with it. But the problem is the size. Sometimes the file is huge, and although I can see the filename in the local folder, it is under a transfering process yet.
Is there any way to trigger an event and to run a script after to receive the entire file?
Thanks for the advice...
Piyux
piyux@hotmail.com


Answer : I wrote a script like this some time ago, and I post it here for your use/modification. It's purpose is to watch a given file's size and to exit when the file size no longer changes. Adding this to your script (or running it immediately before your script) can pause execution until the file transfer is complete.

#!/usr/bin/ksh
rm /tmp/lastsize /tmp/sizediff /tmp/currsize 2>/dev/null 1>&2
touch /tmp/currsize
touch /tmp/lastsize
while :
do
cp -p /tmp/currsize /tmp/lastsize >/dev/null 2>&1
ls -l $1 | awk '{ print $5 }' > /tmp/currsize
diff /tmp/currsize /tmp/lastsize >/tmp/sizediff
if ! [ -s /tmp/sizediff ];
then
break;
fi
sleep 10
done
rm /tmp/lastsize /tmp/sizediff /tmp/currsize 2>/dev/null 1>&2
echo "\a"
echo "\a"
echo "\a"
sleep 2
echo "\a"
echo "\a"
echo "\a"
sleep 2
echo "\a"
echo "\a"
echo "\a"
echo "File is done..."

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 7172441
Asker : thd1811
Subject : ftp: connectio refused
Private : No

Question : I'm running an Ultra10 with Solaris 2.8 and I when I try to connect via ftp from another machine it gives me
connection refused message.

I've checked the /etc/ftpusrrs file,
/etc/shells, /etc/inetd.conf and /etc/services files.
I;ve also checked netstat -a|grep ftp
and it looks like it is listening.

I can do a ftp localhost from the machine and it works fine. A

The /etc/servcies file says ftp-data port 20 and ftp port 21

when I do a ftp <hostname> 21 it works, but isn't the default port 21 anyways.
Why do I have to specify the 21 port?
I'm stumped, please help ,thanks,


Answer : Did you check for the presence/contents of the files:

/etc/hosts.deny
/etc/hosts.allow

?

FUQuestion : Yeah, I just checked and the system does not have any of these files, I have never heard of these files, are they something you would commonly find on Solaris systems? I've heard ot /etc/ftpusers only, thanks,

Thomas

Answer : Check your file:

/etc/shells

If it doesn't exist create it, and in it list your shells and the paths to them:

/usr/bin/sh
/usr/bin/ksh
/usr/local/bin/tcsh


etc....

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities


FUQuestion : Hi Paul, I chek'd the /etc/shells file and everything seems to be there but I still have to specify the 21 port, any more suggestions? thanks,

Thomas

Answer : Check your /etc/nsswitch.conf and ensure that, unless you are using NIS(+) you have "files" then "dns" listed for services.

Also check your /etc/services file and ensure you don't have any duplicate entries for ftp:

cat /etc/services | grep ftp

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

FUQuestion : Hi Paul,

Yeah, everything looks good in the /etc nsswitch.conf file and the /etc/services file, this is a real stumper for me. BTW, what is the difference between ftp and ftp-data in the /etc/services file? and alsi if you have any more places I should check that would be great thanks,

Thomas

Answer : FTP uses ports 20 and 21 for communication/data transfer. Without looking it up I'm thinking that port 20 is the control port and 21 is the data port, but I could have them backwards. Those two entries in /etc/services correspond to those ports.

I found some relevant hits - some info below - have you tried rebooting the box or HUPing inetd?

http://sunsolve.sun.com/pub-cgi/retrieve.pl?doc=fsrdb%2F12116&zone_32=ftp%20%22connection%20refused%22

Also check to be sure the ftp streams line isn't commented out in the /etc/inetd.conf file.


FUQuestion : I haven't tried rebooting the system yet but maybe that will do the trick since everything that we've looked at so far looks ok. Thanks a lot for your help,

Thomas
Rating : 5

Answer : You're welcome...


----------------------------------------------------------------------
QAId : 7172450
Asker : Anonymous
Subject : crontab and mailing
Private : No

Question : hey eveyone,
can any one tell me whether i can run a mail command from crontab.
I have a script that does the following:

wall < delete

where delete is a file

when i try to run this script in a crontab file it dosent seem to want to work and dosent mail all the users. my cron file is :

0 20 * * * mailusers

can any one tell me if this will work and if so, why it wont
thanks !!

Answer : A 'wall' command is a broadcast to all logged in users, not a mail command. Which did you really need? Can you show me the script you're trying to make work so I can see what you're trying to do?


----------------------------------------------------------------------
QAId : 7172457
Asker : bdowns
Subject : Add a permanent route to aix unix
Private : No

Question : I need to add a permanet route to a AIX Unix server on my network. I can add the route normally but every time the server gets retarted the routes are lost. HOw do I add them so they are locked. Thank You

Answer : Just add them to the network startup script for runlevel 2 or 3 (wherever it is in AIX - I forget). Put the same route statement after the interfaces are loaded in the script.

FUQuestion : I am very unfamiliar to how I add it to the scripts... Is there anyway you can point me in the right direction. Where do find the script and how do I edit it? Just a general idea... Thanks

Brian

Answer : Edit the:

/etc/rc.local

file and add your script path/name there.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4


----------------------------------------------------------------------
QAId : 7329034
Asker : collinl
Subject : tar - permission and owner
Private : No

Question : Is there any way I can archive files along with the files' permission settings and owner settings?

Answer : Tar the files up like this to preserve the original owner and permissions:

cd /dir/to/archive
tar -cvpf ../archive.tar ./*


--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 7367408
Asker : plus200
Subject : Reading from a file
Private : No

Question : Hi,

I need to read a whole line from a file into a single variable. The line has unknown number of spaces in it and I need it compleatly in one variable.

Any idea?

Answer : cat file | read nextline

Now $nextline has the entire line in it. To process a whole text file that way:

cat file | while read nextline
do
(whatever operation you'd like to do to each line goes here)
done

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

FUQuestion : Thanks, but...
If the lines have spaces in it, wouldn't it use the space as a delimiter?

I'll check it after the weekend.

Thanks,

Answer : No, the variable "nextline" will contain the entire line in each iteration of the loop. Easily verified like this:

cat file | while read nextline
do
echo $nextline
done

This essentially recreates the 'cat' command, spitting out each line in succession to the screen.

If you *want* to get at the individual pieces of each line you can with something like this:

cat file | while read nextline
do
echo $nextline | awk '{print $2}'
done

This would go through the file and extract and print to the screen the second space-delimited value from each line.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

FUQuestion : Thanks,
But what I need is to pus a HWOLE line into a parameter. I don't Know how many spaces there are in each line so this is the problem...

Answer : I just told you the answer I gave you in the first place will work just fine.

Type in the following:

ksh (ensures you are in a Bourne-compatible shell)
cat file | while read nextline
do
echo $nextline
done

As you can see by the output, when I echo each iteration of $nextline, the content of the variable in every instance IS the entire line. Did you even try the solution I offered? I solved your problem with the first reply.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities


Rating : 5


----------------------------------------------------------------------
QAId : 7367419
Asker : deagle
Subject : cd to directory with space
Private : No

Question : when i ftp into another account from unix command promt, how can i change directory/get files that have a space in the words?

is there a way to find out the name of the file without the spaces?

cheers

Answer : Have you tried enclosing the pathname in double quotes, like this:

cd "dir with space"

As for finding the name you can use a wildcard and avoid the space:

ls dir*

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 7367479
Asker : ronie_san_juan
Subject : UNIX
Private : No

Question : Hi Experts:

My professor gave us this UNIX problem:

Concatenate files intro and chapt1 in the /pub/cis/pclark/DATA
directory, but insert a line of text between them. The line of text is
"Chapter 1: Binary Systems". The files' contents and inserted text
should be displayed on the screen.


I'll appreciate any kind of help. Thanks!!

Answer : cat intro | tee /pub/cis/pclark/DATA/outfile
echo "Chapter 1: Binary Systems" | tee -a /pub/cis/pclark/DATA/outfile
cat chapt1 | tee -a /pub/cis/pclark/DATA/outfile

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 3


----------------------------------------------------------------------
QAId : 7373186
Asker : matciscokid
Subject : unix
Private : No

Question : when I do ls -al command, it give me a full listing of the current directory.
but it doesn't give me a total disk space used on that directory. do I have to added all up or is there a command to do that. I couldn't find any option on ls.

Answer : Use this to find the space taken up:

du -k .

FUQuestion : that gave me total number of blocks for each directory, right?

what if I want to find big files.
example: 100000 + bytes or 100000 -> 200000
Rating : 5

Answer : du -k .

gives you the amount of disk space in kilobytes (1024 in the result being 1 MB).

Doing just:

du .

will give the amount in blocks (usually 512 bytes each) so to figure into MB you'd have to double it (2048 blocks equals 1MB).

To look at them by size:

du -k . | sort -n

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities



FUQuestion : thanks

Answer : You're very welcome...


----------------------------------------------------------------------
QAId : 7383449
Asker : h00k00k
Subject : CDE display resolution
Private : No

Question : How do you set the default screen resolution on a CDE Desktop? OS is SunOs 5.8 on an Ultra 10.

Answer : "The command you use is going to depend on the type of Ultra 10 you have.

If you've got a Creator 3D, the command is "ffbconfig." Full documentation can
be found by reading the ffbconfig manual page: man ffbconfig.
An example of usage:

/usr/sbin/ffbconfig -res 1152x900x76 try

You can get a listing of available video modes by typing:

/usr/sbin/ffbconfig -res

If you don't have a Creator 3D, just replace ffbconfig with m64config."

"Find out what frame buffer type you have
(prtconf should tell you) and run the /usr/sbin/*config command for it."
Rating : 4


----------------------------------------------------------------------
QAId : 7431061
Asker : piyux
Subject : Installing Solaris 7/8 on a Netra t system
Private : No

Question : Since the Sun Netra t System don't have a video card, how to do install Solaris on such systems? just using a hyperterminal connection?
Is there any another way to do it? hyperterminal has lots of graphical limitations...
Thanks for the advice...
Piyux
piyux@hotmail.com

Answer : A nullmodem serial cable and a PC or notebook with a terminal program (there are many besides Hyperterminal) is what you will need. TeraTerm Pro is a good one:

http://download.cnet.com/downloads/0,10152,0-10062-110-890547,00.html?gid=36968&tag=st.dl.10062-100-890547-890547.dln.10062-110-890547

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 5

FUQuestion : Paul, do you know how to sent the Stop+A key to the host whenever using a hyperterminal connection with a regular laptop?
Thanks...
Piyux
piyux@hotmail.com

Answer : Try the following:

Ctrl+d,~,# (Control D followed by tilde followed by pound)

CTRL-BREAK

SHIFT-F5

Barring these get TeraTerm Pro which can apparently send breaks better than HyperTerminal.

http://hp.vector.co.jp/authors/VA002416/teraterm.html

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities






----------------------------------------------------------------------
QAId : 7431094
Asker : plus200
Subject : expr syntax
Private : No

Question : Hi,

I need to do a complecated calculation with expr in ksh.

I need to do something like
expr ($a + $b) % $c
The thing is that for some reason I cant figure how to use "(" ")"

Any idea?

Answer : Can you not just do the calculation in steps? Here's a way to do it:

#!/usr/bin/ksh
a=6
b=8
c=3
i=`expr $a + $b`
i=`expr $i % $c`
echo I equals $i

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4
Rating : 4


----------------------------------------------------------------------
QAId : 7465590
Asker : Anonymous
Subject : Start & Stop Process on Remote Machine
Private : Yes

Question : I am working with Solaris 2.8.

I am trying to write a script that will shutdown an application on a remote Solaris machine.

I have tried to make a script, but the commands I am using aren't working properly.

This is what I tried:

#!/bin/sh
rlogin -l peter 172.22.0.5
cd /bin/
stop_server
exit

This does not work, It gets me to the machine alright, but stop there.


I tried this too:
#!/bin/sh
rsh -l peter 172.22.0.5 /bin/stop_server

This doesn't fully work. It runs the executable from the remote machine, but the executable tries to execute on my machine.

How can I write a script that will start and stop an application process on a remote machine instead of trying to execute the remote command on my local machine?

I hope you understand. Thanks!

Answer : Try using rexec to execute commands on the remote machine ON that machine.


--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

FUQuestion : Where can I find rexec for Solaris. It didn't come with my OS (2.8).

Thanks!

Answer : Hmmm I have the man pages for it, but no rexec either. It must not get installed by default. I found out by poking around the net that it is a C function included with the OS but no binary that uses it is included. I also wanted to mention that using the r* tools is considered bad form from a secruity perspective - they are very insecure (especially rexec). You can get it here if your sure security will not be a concern:

http://www.siscom.net/~welter/professional/scripts/rex.txt

Save that as a file named /usr/bin/rexec on Solaris and then do a

chmod u+x /usr/bin/rexec

to be able to execute it.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

FUQuestion : Thanks. That works fine.

I just need the command syntax please.

rexec ? ? ? ?


Answer : I believe it will be:

rexec hostname username password "command"

Put quotes if the command has spaces - try it with or without spaces.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4
End :


----------------------------------------------------------------------
QAId : 7471565
Asker : Anonymous
Subject : Script to check if a machine is Up and Running
Private : Yes

Question : Solaris 2.8

My script isn't working and I don't know why. Can you help?

Here is what I tried so far.

#! bin/sh
#
primary="'ping 172.22.0.2 | egrep alive'"

if [ "$primary" ]
then
echo ""
echo " --> Primary Server Accessible <--"
echo ""
else
echo ""
echo " --> Primary Server NOT Accessible <--"
echo ""
fi
#

Answer : Part of your problem is that you are assigning "primary" the value of "ping 172.22.0.2 | egrep alive", not the *result* of those operations. You've simply assigned that *text* string to the variable. Then later in your test (if [ "$primary" ] ) you do not compare it to anything.

To get the result of the operation you need to not enclose it with double quotes, but rather backticks (usually an on the same key as the tilde (~) so your assignment would look like this:

primary=`ping 172.22.0.2 | egrep "alive"`

Note the backticks around the whole thing. This means process the inside, executing any commands encountered and give me the result of those commands when done.

Then in your test you need to compare your variable's value to something, for example:

if [ "$primary" = "172.22.0.2 is alive" ] ;
then
echo "Server is up";
else
echo "Server is down";
fi

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities



Rating : 5
End :


----------------------------------------------------------------------
QAId : 7499792
Asker : Anonymous
Subject : Replace lines in Files
Private : Yes

Question : OS: Solaris 2.8

I have 2 files on 2 different machines.

There are 2 lines in the files that need to be identical.

How do I:

1) Copy the 2 lines from the main file to a temporary file.

2) Replace the 2 lines (copied from the 1st file) in the 2nd file with the 2 lines in the temp file.

I hope you can understand this.

Thanks!

Need More Information : Can you show me the example text that would be in the filed before and after the script is run so I can see what it is you're trying to do?

FUQuestion : Here is what file 1 looks like:

[ROUTER]
Local = 0
Machine = localhost
Service = 9032
Tempo = 10

[BASE]
date_base=20020326
heure_base=00:20
etat_base=0
Last_Base=19990122


Here is what file 2 looks like:

[ROUTER]
Local = 0
Machine = localhost
Service = 9032
Tempo = 10

[BASE]
date_base=20010706
heure_base=00:20
etat_base=0
Last_Base=19990122


I want to be able to run a command that will replace " date_base=20010706 " with " date_base=20020326 ". Being that this is an .ini file, it must stay in the same place. This command will be used in a batch file so it can not be a vi kind of editing.

Thanks!

Answer : OK I wrote you a perl script to handle this task. Here it is:

#!/usr/bin/perl
open(file1, "/tmp/file1") || die "Sorry, I could not open /tmp/file1 for reading. System error message was: $!\n";
open(file2, "/tmp/file2") || die "Sorry, I could not open /tmp/file2 for reading. System error message was: $!\n";
while (<file1>) {
$x = index($_,"date_base");
if ($x != -1) {
$s = substr($_,10,1000);
}
}
open(outfile, ">/tmp/outfile") || die "Sorry, I could not open /tmp/outfile for writing. System error message was: $!\n";
while (<file2>) {
$x = index($_,"date_base");
if ($x != -1) {
print outfile "date_base=$s";
} else {
print outfile $_;
}
}
close(file1);
close(file2);
close(outfile);
system("rm /tmp/file2 >/dev/null 2>&1");
system("mv /tmp/outfile /tmp/file2 >/dev/null 2>&1");

This script assumes that the files to be processed are in /tmp and are named 'file1' (file with the value of date_base that we want) and file2 (the file that needs it's date_base value replaced). If you want to change it just change the lines where you see me "open" those files with their paths.

Save this to a file and then do this to enable it to run (also be sure to change the first line if your perl is not at /usr/bin - find yours with a "which perl" command):

chmod u+x switch.pl (to give it permissions to run)

./switch.pl (to actually run it)

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

P.S. Please do not ask questions of this sort as private. This is not a private question or of an embarrasing nature, and marking it private means no one can read and learn from our interaction.


FUQuestion : Thanks for your help!

I won't ask anymore private questions unless they are private.

When I do " which perl ", it is no located on my Solaris 2.8 machine. Do I have to install it? Or is it just one binary file? Where can I get it?


Answer : It can be gotten here:

http://www.sunfreeware.com/programlistsparc8.html#perl

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4
End :


----------------------------------------------------------------------
QAId : 7509976
Asker : Anonymous
Subject : mount problem
Private : No

Question : Hello,

i am working on SunOS 5.5 and a i try to mount a remote dir to localdir but it gives me some errors..


#mount isws09o:/REMOTE_PLANET /PLANET_LOC
nfs mount: isws09o :RPC: Program not registered
nfs mount: retrying: /PLANET_LOCAL
....

and it coulndt..

what is wrong?
thanks and regards..

Answer : The remote machine needs the entries for what to share in:

/etc/dfs/dfstab

If those are not present it will not start the NFS daemons at boot time, and will generate that error.

You can start them manually after adding the dfstab entries thusly:

/usr/lib/nfs/nfsd -a 16
/usr/lib/nfs/mountd

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities


Rating : 4


----------------------------------------------------------------------
QAId : 7529519
Asker : Anonymous
Subject : Telnet & FTP
Private : No

Question : OS: Solaris 2.8

Is there a way to filter which IP addresses are allowed to telnet & FTP to my machine in Solaris without using a third-party firewall?

Answer : Go and download TCPWrappers - it can restrict access to the services you're looking to protect.

http://www.sunfreeware.com/

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities


Rating : 4
End :
Rating : 4


----------------------------------------------------------------------
QAId : 7550236
Asker : Anonymous
Subject : TCP Wrapper & CC Compiler
Private : No

Question : You recommended this application to solve my FTP & Telnet filtering problem.

I have spent days trying to get this thing to work.

It is aggravating.

I am getting this error message:

/usr/ucb/cc: language optional software package not installed

I downloaded gcc, and replaced the cc binary with gcc.

Maybe this was dumb, but it still didn't work.

I got this error message:

cc: 1: not found
cc: BEGIN: not found
cc: object: not found
cc: ARGV[1]: not found
cc: syntax error at line 2512: `{' unexpected
*** Error code 2
make: Fatal error: Command failed for target `tcpd.o'
Current working directory /export/home/tcpwrap
*** Error code 1
make: Fatal error: Command failed for target `sunos5'

Any suggestions on how I should install TCP Wrapper?

Answer : Did you follow the instructions with the tcpwrappers (probably a file named README)? If so, it probably suggests that you do a:

./configure

before a make. Have you done that? If you've gotten your wires crossed you can do something along the lines of:

make clean

Also ensure you have all the library paths in your LD_LIBRARY_PATH variable - check it with:

echo $LD_LIBRARY_PATH

Also ensure your PATH is set with the following in it:

/usr/ucb:/usr/ccs/bin

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Answer : Also this tutorial may help (if you're on Solaris):

http://www.kempston.net/solaris/tcpwrappers.html
Rating : 4.9
Rating : 4.9

FUQuestion : Thanks! I was able to get somewhere with the new directions. But it still gives me some errors:

It looks like this:

/usr/ccs/bin/as: "/var/tmp/cc6SZdFi.s", line 91: error: unknown opcode ".subsection"
/usr/ccs/bin/as: "/var/tmp/cc6SZdFi.s", line 91: error: statement syntax
/usr/ccs/bin/as: "/var/tmp/cc6SZdFi.s", line 103: error: unknown opcode ".previous"
/usr/ccs/bin/as: "/var/tmp/cc6SZdFi.s", line 103: error: statement syntax
*** Error code 1
make: Fatal error: Command failed for target `update.o'
Current working directory /export/home/tcpwrap
*** Error code 1
make: Fatal error: Command failed for target `sunos5'

Any other suggestions?

Need More Information : What version of Solaris are you using?

I'd suggest getting just the C compiler working first. Ensure you have only one 'gcc' and or 'cc' in your PATH ("which cc", "which gcc", "find / - name gcc", etc). You may find some of the existing 'cc' or 'gcc' are symlinks to the real thing. You may want to point those to the real executable you're currently using. Once you get the gcc to work on a basic hello.c file (below) then go back, nuke the extracted directory, extract it again and ensure you have all the PATH and LD_LIBRARY_PATH info correct (mine are immediately below)

[ped@]elfstone] /export/home/ped $ echo $PATH
/bin:/usr/bin:/usr/ucb:/usr/bin/X11:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/ccs/bin:/usr/ucb/bin:/export/home/ped/scripts:/usr/sbin:/usr/bin:/usr/openwin/bin:/usr/dt/bin:/usr/local/samba/bin:/export/home/ped/scripts:.

[ped@]elfstone] /export/home/ped $ echo $LD_LIBRARY_PATH
/usr/local/lib:/usr/local/X11/lib:/usr/lib:/usr/openwin/lib

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

FUQuestion : I have Solaris 8.

What is the binary as used for?

And do you have any suggestions to why it wouldn't work?

Need More Information : Are you still not getting anywhere with it? Can you give me more details (name of the archive, directories involved, commands issued, etc)? I've seen the errors with "as" before, but I can't remember what caused them. Did you get the gcc from http://www.sunfreeware.com?

Answer : I found some relevant info for you - grab the corresponsing "binutils" package from sunfreeware.com and install that too. It apparently replaces the assembler that comes with Solaris which is the 'as' command that is giving you trouble.

FUQuestion : Paul,

The gcc works fine.
The binutils fixed the problem.

I was able to create the binary files.

I made the hosts.deny and the hosts.allow files.

I can't get it to work with the FTP though.

Here is what I have:

hosts.deny
ALL: ALL

hosts.allow
in.ftpd: 172.22.0.58


When I ftp from 172.22.0.58, it doesn't work. If I put ALL: ALL in the hosts.allow file, everything works.

What am I doing wrong?

(ALL: 172.22.0.58 doesn't work)

Answer : Great! Now consult the URL I gave you near the top and use their technique to watch the log messages being generated when you attempt to connect via TCP Wrappers-protected services. They have steps in the tutorial to tell if you're getting the proper result or not.

FUQuestion : Thank you! Everything seems to be working fine now.

Except, I have no logs. Nothing is showing up in the syslog.

Thanks for all your help. You were wonderful!
End :


----------------------------------------------------------------------
QAId : 7562947
Asker : kimigayo
Subject : repalce
Private : No

Question : hi, how can you replace certain words that sit
across multiple files ?

if you can't, i think you can create a batch file that does the replace function to files that is specified in the batch.
I have tried to make one, it is not like DOS and can't even run the script.

Can you please show me how to do these?

Thanks in advance

Best regards
Tomo

Answer : How about something like this, where the word I'm searching for is 'stuff' and I want it replaced with 'mystuff' in all the files:

#!/usr/bin/ksh
for i in $*
do
cat $i | sed -e 's/stuff/mystuff/g' > /tmp/xyz
cat /tmp/xyz > $i
done

For testing I invoked it as follows:

./replace.ksh file1 file2 file3

The files contained the following:

file1:
This is an example of stuff that should be replaced.

file2:
Another example of
stuff
I want replaced.
This stuff has got to stop!

file3:
YASINR - Yet Another Stuff I Need Replaced - is this stuff getting boring yet?


When done all the files have the term 'stuff' replace with 'mystuff'.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4


----------------------------------------------------------------------
QAId : 7599107
Asker : Anonymous
Subject : Fortran compiler
Private : Yes

Question : For Solaris 7 where can I find fortran compiler?
Thanks

Answer : http://www.sunfreeware.com/
Rating : 5


----------------------------------------------------------------------
QAId : 7606175
Asker : aliedk
Subject : format
Private : No

Question : hi (i am pretty new in unix)

I have a 18gb disk and i mirrored it from 2gb disk. At this time i never new that it is not a good idea to use dd if the target is much bigger than source. My question is : is there any way to get back all the space i lost ?? i tried formatting it again. the partitions are still there and size still shoes 2gb.

Thanks in advance.

Answer : You might try using fdisk in UNIX to re-setup the slices, and then use cpio or tar to copy the original smaller disk's slices to the new one.

OR

Boot on old disk and mount new disk's filesystems by slice number under /mnt (ex /mnt/s0, /mnt/s3, etc) then use:

cd /oldfilesystemroot
cp -pr ./* /mnt/s0/.

to recursively copy all data. When it's done switch the hard disks (may need to do an installboot to make the new disk bootable).

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 7608309
Asker : ho_robert
Subject : 64 bit Vs 32 bit
Private : No

Question : how to determine the sun solaris supporting 32 or 64 bits? my machine is e250 and using Solaris 8 as os.


thx

Answer : isainfo -kv

will report on whether the drivers currently loaded are 32 or 64-bit which should in all cases ocrrespond with the running kernel.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 7610079
Asker : guy_ellery
Subject : find command
Private : No

Question : Paul,
I want to find all files within a directory (and only that directory) that have a date modified of 90 days or more. Once found I would like to mv these files to a sub-directory - hence find ONLY on the parent directory. Essentially archiving the files.
I had a command working on HPUX but it does not work on SunOS 5.8. The command is:

function findfile {
dir=$MQM_REPORTS/edi_archive
if [ ! -d $dir ]
then
mkdir $dir;
fi
while read files; do
mv "$files" $dir
done
}

file_type=$1
##### GE (1.2)
##### find $MQM_REPORTS -name "$file_type*" ! -atime 90 | grep $MQM_REPORTS/"$fi
le_type*" | tee newfile.log > /dev/null 2>&1
#####
find $MQM_REPORTS -name "$file_type*" -atime +90 | grep $MQM_REPORTS/"$file_type
*" | tee newfile.log > /dev/null 2>&1

findfile < ./newfile.log

I have run the find on its own and it does not return the expected files. I have changed it to add ! before the -atime and this brings back ALL the files, even those <90 days old.

This problem lies on the SunOS but I have played around with the find command to no avail.

What else can I try?

Regards,
Guy Ellery

Answer : Have you tried it with '-mtime' instead of '-atime'?

Also I see an efficiency thing. Here is a line from your script:

find $MQM_REPORTS -name "$file_type*" -atime +90 | grep $MQM_REPORTS/"$file_type
*" | tee newfile.log > /dev/null 2>&1

where at the end you're making a log file.

It would be better expressed like this:

find $MQM_REPORTS -name "$file_type*" -atime +90 | grep $MQM_REPORTS/"$file_type
*" > newfile.log 2>&1




Answer : Oops - that end piece should be:

2>/dev/null
Rating : 5


----------------------------------------------------------------------
QAId : 7628173
Asker : Anonymous
Subject : Does UNIX Mail (and/or PINE) display IP Address for Email
Private : Yes

Question : Hi there,

Can someone tell me if the unix command "mail" and/or the pine tool captures IP Addresses from received emails and can display them?

How would you do this if it is possible?

Thanks

Answer : Pine:

Enable the full header command. (NOTE: This step only needs to be done once. The change is permanent.)
Type 's' for Setup
Type 'c' for Config.
Scroll down the list of features until you find enable-full-header-cmd, and type 'x' until you see an 'X' in the checkbox.>
Type 'e' to Exit.
Answer with yes (by hitting 'y') when it asks you to replace settings.
Select the message in question.
Press the [Enter] key to view it.
Press 'h' to display the full header.

Rating : 5


----------------------------------------------------------------------
QAId : 7633350
Asker : Anonymous
Subject : unix and NT server directory sharing
Private : No

Question : Hello,


we have a NT 4.0 server in our office and some Sun Sparc Unix workstations too.

But we want to use unix ws and NT server together in an application so we need to mount a Unix directory onto a NT server directory...For this purpose we tried to configure MS SFU utility on NT server by "server for NFS" chose, but it didnt work..

on the other side,unix side solution as fas as we know "samba" source code needed to be complied and failed...

so can you help us

thanks...

Answer : A quick and easy way to accomplish this from the Sun (mapping an NT drive) is with Sharity. It will allow you to mount remote shares on NT machines as mount points on your UNIX filesystem.

http://www.obdev.at/products/sharity-light/


----------------------------------------------------------------------
QAId : 7651469
Asker : plus200
Subject : Getting the time in seconds
Private : No

Question : Hi,

I need to measure the time for a certain part of my script.

I want to take the time before and after this section and compare them.

Is there a way to get the time in seconds so I can subtract? (it's very easy to do that in perl but ho do I do it in ksh??)

Thanks,

Answer : You can use the command "time" to time a process. For example is Solaris 8 I ran the a command and got the response shown:

[ped@]elfstone] /export/home/ped $ time cat /etc/host* | egrep xyz

real 0m0.09s
user 0m0.01s
sys 0m0.06s

FUQuestion : Thanks but --- I need it in absolute value since this is also used to be sent to another process (watchdog).

any idea?

Answer : Try adding this before and after for the section you want to time:

before=`perl -e 'print time;'`

after=`perl -e 'print time;'`

Note those are backticks (`) around the perl section.

That command should put the number of seconds since the beginning of UNIX which you can then subtract to find how long the script took.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4
Rating : 4


----------------------------------------------------------------------
QAId : 7653539
Asker : Anonymous
Subject : Is it possible to CHMOD files in UNIX account on login?
Private : Yes

Question : Hi Paul,

Can you tell me how i can set my UNIX account so that when i login it will "chmod" certain files that are in my account.

For example, if i wanted to "chmod 744" to ALL files in my account when i login how would i do this? Do i write something in the ".login" file or ".cshrc" file or something?

I am using a sun unix box (shell: tcsh)

Here are the files i have visible in my unix account:

.Xdefaults
.alias.sun4u
.cshrc
.dtprofile
.login
.mwmrc
.profile

Thanks

Answer : If your default shell (set in /etc/passwd on your account line) is set to sh or ksh (/usr/bin/ksh) then you can edit the .profile and add a line similar to this one:

chmod 777 /export/home/username/deleteme/*

and all files in directory /export/home/ped/deleteme will be set to full permissions.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Answer : P.S. Please do not ask questions of this sort as private. This is not a private question or of an embarrasing nature, and marking it private means no one can read and learn from our interaction.


Rating : 5


----------------------------------------------------------------------
QAId : 7667224
Asker : Anonymous
Subject : Setting CHRONTAB to mail me my 'Sent-Messages'
Private : No

Question : Hi there,

Is it possible to set up a chrontab operation in my account so as to send me mail that is located in my "~/folder/sent-messages" file (~ being my home directory)? I am very new to UNIX so i have no idea how to do this. My shell is "tcsh". I believe when i log out i guess the chrontab feature will be lost or will it? I would like this chrontab to send me these messages every 1 week if possible.

Because the "sent-messages" file can be really big after time can someone also tell me how to just send the last 4 sent messages located in this file? I can use the "tail" command but it would be nice to no exactly where the 4 last messages are so it can chrontab to send those only.

Tbanks very much


Answer : You can create a crontab with:

crontab -e

You may need to set EDITOR and/or VISUAL environment variables prior to running the command - I'd set both like this:

EDITOR=/usr/bin/vi
VISUAL=/usr/bin/vi
export EDITOR
export VISUAL

Once inside the file add a line at the bottom like this:

* * * * 6 /usr/local/scripts/sendmemymail

Save it with <ESC>, followed by :wq

As for the sendmemymail command make sure it starts with:

#!/usr/bin/ksh

as the first line. Then to send the mail in the script use:

cat ~/folder/sent-messages | mail myemail@myisp.com

I don't know the format of your emails so I can't really suggest a way for you to prune out the last 4 exactly, but you can always use tail with a parameter to grab the last 100 lines or so:

cat ~/folder/sent-messages | tail -100 | mail myemail@myisp.com

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4.9
Rating : 4.9


----------------------------------------------------------------------
QAId : 7667931
Asker : Anonymous
Subject : Modifying Dates of Existing UNIX Files?
Private : No

Question : Hi there,

Sorry for the previous empty question...accidentally clicked the wrong button.

Would you know if it is possible to modify an existing date for a file within a unix account? I would like to experiement with this.

Thanx a lot

Answer : Try it this way:

touch -m -t 04012359 file

which would set 'file' to April 1 at 11:59 PM (2359).

You may also want to try it this way:

touch -a -t 04012359 file

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4.9
Rating : 4.9


----------------------------------------------------------------------
QAId : 7671202
Asker : thd1811
Subject : file to control access in Solaris
Private : No

Question : is there a file that controls access like telnet and ftp in Solaris that is built in? soemthing like hosts.deny in linux?
thanks

Answer : You'll need to install TCPWrappers to get the use of /etc/hosts.[deny|allow] and control access to individual services. You can get it here:

http://www.sunfreeware.com

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4


----------------------------------------------------------------------
QAId : 7672604
Asker : Anonymous
Subject : Setting CHRONTAB to mail me my 'Sent-Messages'
Private : No

Question : Hi there,

Is it possible to set up a chrontab operation in my account so as to send me mail that is located in my "~/folder/sent-messages" file (~ being my home directory)? I am very new to UNIX so i have no idea how to do this. My shell is "tcsh". I believe when i log out i guess the chrontab feature will be lost or will it? I would like this chrontab to send me these messages every 1 week if possible.

Because the "sent-messages" file can be really big after time can someone also tell me how to just send the last 4 sent messages located in this file? I can use the "tail" command but it would be nice to no exactly where the 4 last messages are so it can chrontab to send those only.

Tbanks very much

Answer : I already answered this one privately, but since it's here too I'll duplicate the answer here:

You can create a crontab with:

crontab -e

You may need to set EDITOR and/or VISUAL environment variables prior to running the command - I'd set both like this:

EDITOR=/usr/bin/vi
VISUAL=/usr/bin/vi
export EDITOR
export VISUAL

Once inside the file add a line at the bottom like this:

* * * * 6 /usr/local/scripts/sendmemymail

Save it with <ESC>, followed by :wq

As for the sendmemymail command make sure it starts with:

#!/usr/bin/ksh

as the first line. Then to send the mail in the script use:

cat ~/folder/sent-messages | mail myemail@myisp.com

I don't know the format of your emails so I can't really suggest a way for you to prune out the last 4 exactly, but you can always use tail with a parameter to grab the last 100 lines or so:

cat ~/folder/sent-messages | tail -100 | mail myemail@myisp.com

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

FUQuestion : Hi Paul,

I got this code from CHL (another expert) but i cant seem to be able to get it working. It is able to send me the last 4 msgs in the "sent-mail" file. Unfortuantely, I always get the same error msg:

awk: syntax error near line 7
awk: illegal statement near line 7
awk: bailing out near line 8
No message !?!

Here is my script file:
-------------------------
#!/usr/bin/ksh
tail -r folder/sent-mail > re

cat re | awk '
BEGIN {
count=0
}
/^From/ { count = count + 1 }
{ if ( count < 4 )
then { print }
else { print;
exit
}
}' > chopped

tail -r chopped | mail howdy@woof.com
------------------

Any clues?
And is it possible to turn off crontab from sending me email msgs if errors occur in the crontab task?

Answer : I fixed it for you:

#!/usr/bin/ksh
tail -r /wherever/home/myhomedir/sent-mail > /tmp/reversed
cat /tmp/reversed | awk 'BEGIN { count = 0 }
/^From:/ { count++ }
{ if (count < 4) print
else {
print
exit
}
}' > /tmp/chopped

echo "LAST 4 MESSAGES" >> /tmp/chopped
tail -r /tmp/chopped | mail myemail@myisp.com

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4.9
Rating : 4.9


----------------------------------------------------------------------
QAId : 7734026
Asker : Anonymous
Subject : Connecting to a Network
Private : Yes

Question : Hi
if I want to connect my sun workstations (Solaris 7) to my network domain.
what files should I work with and what information do I need so that I can telnet this work station from the network?
Thanks

Need More Information : You will need to do several things:

Use "ifconfig -a" to view your interfaces - the lo0 is your loopback device and can be ignored. The other is your ethernet.

Use ifconfig xx0 inet w.x.y.z netmask 255.255.255.255 up

to set the IP and netmask for your ethernet.

Then you need to create a single-line text file called /etc/defaultrouter that has the IP address of your gateway device (example - if your IP was 210.234.123.43 your gateway might be 210.234.123.1).

Also create a single line file called /etc/defaultdomain and in it put the DNS domain your machine will belong to - ex:

mydomain.com


Next you need to edit /etc/nsswitch.conf and be sure the line that starts with "hosts" has "files dns" to the right of it.

Next you need to edit /etc/resolv.conf and enter your domain, search domains and DNS servers. It will appear like this:

search mydomain.com
nameserver 137.12.43.11

Finally you will need to make an entry in your /etc/hosts file that has your IP address associated with your hostname (you can find out exactly what your machines hostname is by simply typing hostname at a prompt). The line should appear similar to this:

210.234.123.43 hostname hostname.mydomain.com loghost

Now you should be online after a reboot.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

FUQuestion : Thanks for the excellent answer but I can't find the evaluation section on this question so kindly answer this question again it may appear the evaluation.

Answer : You're welcome. Just click one of the stars you see down near the bottom to rate the answer, and if you have something to say add it in the box.
Rating : 5

FUQuestion : I have started a course on solaris training what do you advise me in the following:
1. I'm intending to be sun certified admin/engineer but things are not clear about the future is this track good ? or there is a better track?
appreciating your advise.

Answer : If you become proficient at Solaris (Sun's UNIX - a leader in the UNIX arena) you will be well prepared with 95% of the same skills you'd need in any UNIX you may come into contact with. I would continue with your direction of study.


----------------------------------------------------------------------
QAId : 7762364
Asker : Anonymous
Subject : Virtual Memory
Private : Yes

Question : Hi,
I have Ultra 5 Sun Machines with Solaris 7.
How can I increase the virtual memory? what is the command ?
I'm log in as ROOT
Thanks

Answer : The best way, of course, is to include all the swap you'll need when laying out the disk. But since you're already past that and need more you can add some like this:

mkfile <size> filename
swap -a filename


example:

mkfile 128M myswapfile.swp
swap -a myswapfile.swp

Be sure to add this to your startup scripts so it's there after a reboot (if the file is already made with mkfile you'll just need the second line in the scripts at startup - be sure to specify the full path to the myswapfile.swp file).

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

P.S. Please do not ask questions of this sort as private. This is not a private question or of an embarrasing nature, and marking it private means no one can read and learn from our interaction.



Rating : 5


----------------------------------------------------------------------
QAId : 7763526
Asker : anupam4u
Subject : ps command not working on solaris 2.6
Private : No

Question : hi
i m using a sun ultrasparc 60 machine having Solaris 2.6 O.S suddenly it start giving an error

"sh: /var/spool/.recent/.ps_filter: cannot execute"
when i write ps at console

anybody help me out of this problem

regards
anu

Answer : I'm not sure where the ".recent" dir came from - I would suggest that perhaps that if that dir were removed (or the .ps_filter file beneath it) the ps would run fine. Check the contents of the dir to be sure it can be safely deleted and then:

cd /var/spool
rm -Rf .recent

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

FUQuestion : thanks paul
acctually it didn't work but what i find is that this dir ".recent" doesn't exist in another sun machine. so i checked the logs and find there is some person who did this ...he made some scripts and content of script is somewhat like this

PATH=/opt/UWpine/bin:/usr/bin
ps $*|grep -v "raise" |grep -v "bash" |grep -v "annit" |grep -v "rpcstat" |grep
-v "rinetd"\
|grep -v "pts.*7"

note annit is the name of that person..

when i deleted that directory sys still giving same error
so how can i restore it back?




Answer : Try doing a :

which ps

to find out where the executable you're running is stored. If the ps you're running is not under a normal bin directory then try looking for all occurrences:

cd /
find . | egrep ps


--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Answer : I meant to add that once you found where the "real" ps lies - not a script named ps, perhaps that your friend wrote to supplant the real ps command, which is what I suspect is going on here - then execute it with a full path, like:

/usr/sbin/ps.bak -ef

and see if it works as expected. He probably renamed the original ps as ps.bak or ps.orig or something similar. You will find it with the find command I showed above.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4

FUQuestion : hi paul
what u r prediciting is right...coz i yesterday find the real problem....actually he made backup in the same directory and i tried that command and it worked fine...one more thing paul he was using some raise command for gaining the root access...and before leaving he deleted all the logs entry ...now i understand his whole setup ...anyways i capture what he was doing with sys..and now he is in trouble...

so again thanks paul....can u tell me how to avoid this in future ....any references for that from where i can get more information...

thanks
anupam



Answer : You can use a program called TripWire to catch this type of thing in the future. It will watch for file changes (including size) and will alert you if a file changes.

http://wwws.sun.com/software/security/tripwire/

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4


----------------------------------------------------------------------
QAId : 7836395
Asker : piyux
Subject : Sun Solaris - How to send an email from command line
Private : No

Question : Hi, please give and advice regarding the following issue...

I use something like #/bin/mail -sReport me@comp.com /var/log/messages from my linux boxes to send some reports. I need to do the same thing from solaris boxes. I tried this command but it doesn't work.
Can you give me an advice about what is wrong or how to do it from solaris 7/8?
Thanks a lot !

Piyux
piyux@hotmail.com

Answer : cat /var/log/messages | mail me@comp.com

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 7864694
Asker : Anonymous
Subject : Disk Management
Private : Yes

Question : OS: Solaris 5.8

How do I check the total capacity of a hard drive?

I tried df -k but that only displays mounted paths.

If I want to mount /export/home with all free space on the disk, how can I do that?

I know that I have to edit /etc/vfstab, and add the entry there. But how do I determine what partition has the free space?

In the /etc/vfstab file, I see /dev/dsk/c1d0s2, /dev/dsk/c1d0s1, /dev/dsk/c1d0s5, /dev/dsk/c1d0s6.

How do I determine how much space is allocated to each /dev/dsk/c1d0s?

Thanks!

Answer : I'm not sure what you mean "but how do I determine what partition has the free space?" You don't need free space to mount a partition. It has the space. You just pick a directory where you want that filesystem to exist and mount it there. For example (simplified):

mkdir /mystuff
mount /dev/dsk/c0t0d0s4 /mystuff

The contents of that partition are now accessible at /mystuff.

The total capacity of a hard disk can be found by it's ID string in /var/adm/messages or by issuing the 'dmesg' command and looking for the hard drive model in there. Also you can use 'fdisk' to examine thd disk and see how many total cylinders there are and from there can calculate the total space, as well as for each partition.

As for mounting /export/home with "all free space" - I assume you mean mount an empty partition there. You will first need to create an empty partition with fdisk, then mount that filesystem to /export/home as I described at the beginning and you'll be in business.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 3
End :


----------------------------------------------------------------------
QAId : 7914033
Asker : subirp
Subject : monitor log errors
Private : No

Question : A question right up your alley, Paul.
How would write a script in UNIX to constantly monitor a (syslog.log) log file for the word "ERROR or WARN" and mail me the line of the error if the script finds the "ERROR" in the log.

I know I can use some combination of these command : "tail -f syslog.log" along with
"egrep -i 'ERROR|WARN' | mail -s "SYSLOG ERROR" myself@domain.com" but do not
know how to put it in a script and to run 24 by 7.
Any other sugges. are welcome
Thanks a lot.

Need More Information : How about just do what you've shown above in a script and schedule it with cron (crontab -e) to run every 1-5 minutes? The only problem I see with that approach is that you will continute to get warning emails from items in the log file you've already alerted on. IOW - until the file is cleared out you will continue to find the same ERROR or WARN messages. So you may want to make a backup copy of the file when you send the alert and then cat /dev/null over the current file so you won't catch the same errors again.

FUQuestion : Paul,
Thanks for the quick response and tips. Would you know as to how I can grep the "ERROR" line and 4 lines prior to it and send me an email. How would do in a UNIX script, basically ? Usually , our log files show the problem b4 the ERROR message appears in the log.
Thanks a bunch

Answer : Check out the script in this answer I gave on a similar subject. The script would be very close to this.

http://www1.askme.com/MyXpertise.asp?pm=va&method=ans&cid=2239&page=1&vid=7672604
Rating : 4.9
Rating : 4.9


----------------------------------------------------------------------
QAId : 7919675
Asker : kimigayo
Subject : extract
Private : No

Question : I have a simple text file that looks like this.

rrrrrr tttt 44444
rrere fdfed 33333
fafda fafa 93933

now I just want to extract numbers from this file into another file. Is that possible?

Answer : Sure thing:

ksh (just to ensure you're in a Bourne-compatible shell)
cat file1 | while read line
do
echo $line | awk '{print $3}' >> /tmp/file2
done

Now all the sets of numbers will be in the file /tmp/file2 when done.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 3

Answer : I'm curious about what part of the answer was incomplete, leading you to give it three stars, but was not so incomplete that you would ask a followup question to clarify?


----------------------------------------------------------------------
QAId : 7937340
Asker : cppdsib
Subject : sun solaris tar file restoration
Private : No

Question : How to restore files from a tape archive to a specified directory . Files backed up using solaris 5.8 tar utilty ?

Answer : First verify whether the files were tarred with absolute pathnames or relative pathnames with a table of contents tar listing:

tar -tvf /dev/rmt/0cn | more

where "0cn" is your tape device.

Then once you know that you can restore with relative pathnames (that is, the files are not stored relative to root (/) in the tar archive) you can restore with this:

cd /where/Iwant/toput/thefiles
tar -xvpf /dev/rmt/0cn

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities



----------------------------------------------------------------------
QAId : 8084218
Asker : bass_box
Subject : copy files
Private : No

Question : Hi there

I am making a script that will copy files from one Solaris box to another. I know the list of files I want, so how do I initiate a script that effectively is an automated FTP copy from one box to another?

Answer : Here's a nice way to do it:

http://www.columbia.edu/kermit/ftpscript.html

Another easier way is to create a file named .netrc in your home directory, then chmod it:

chmod 600 .netrc

Inside the .netrc put this line:

machine othermachine.mydomain.com login <username> password <password>

Now that this file is in place (and protected from view) you can put something similar to the following into another script file to automate FTP sessions to 'othermachine':

ftp othermachine.mydomain.com 1>/dev/null <<!EOF
bin
prompt
lcd /var/tmp
cd backup
mput *.gz
bye
!EOF

In the example above I connect to the remote machine, change the transfer type to binary (bin), change my local dir to /var/tmp, change the remote directory to ./backup, and then do a multi-put of all *.gz files from /var/tmp to the remote machine's ./backup directory.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 5


----------------------------------------------------------------------
QAId : 8084373
Asker : bass_box
Subject : finding files
Private : No

Question : Hi there

How do you find file names only through the entire directory?

I do not want to find text in files. Just a file name in the directory.

thanks

Answer : Say you are wanting to search /usr (whole branch including subdirectories) for a filename of 'myfile' (you can also use wildcards here):

cd /usr
find . | egrep myfile

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4


----------------------------------------------------------------------
QAId : 8084384
Asker : jment
Subject : redhat 7.2
Private : No

Question : hi,
i am using redhat 7.2 and had chosed GRUB as the boot loader. at the sametime, and in the same pc, i use windows 98, so with GRUB i could chose which OS to be loaded.
my question is, how to configure GRUB after we have already installed redhat. i want to changed the default OS to boot and the default time.
please help me.

Answer : http://www.freeos.com/articles/3482/

"Configuration

GRUB provides a menu-based interface that you can use. By default GRUB will install into /boot/grub and the configuration file will also reside there. The default configuration file is menu.lst. This is the GRUB equivalent of lilo.conf. This is the file where you define the various boot options, boot images etc.

A sample menu.lst file is given below

timeout 5
color black/yellow yellow/black
default 0
password freeos

title My Linux
kernel (hd0,1)/vmlinuz root=/dev/hda3 idebus=66

title Another Distro!
kernel (hd0,6)/boot/vmlinuz root=/dev/hda7 idebus=66

title Windows
root (hd0,0)
makeactive
chainloader +1

Let's look at the configuration options given here

timeout - The delay in seconds before the default entry is booted.

color - The color combination for the menu. The first entry is the foreground and background color of an entry in the menu and the second is the color combination to be used when a entry is highlighted.

default - The default entry that will be booted after the timeout value is reached. Here we've given '0' as the default. This means that the first boot entry will be used. GRUB counts up from '0' and not from '1'. So the first entry would be '0' and the second '1'.

password - This is the password to be used if someone wants to access GRUB's advanced features at boot. GRUB puts some very powerful features at your disposal because of its ability to read filesystems. For example, at the grub boot prompt, someone can just type 'cat /etc/shadow' and read your shadow passwords -- without even booting into your system! Using a password restricts such actions to authorized users only. This password will also be used to prevent booting of other users.

Now come the boot entries. Each boot entry starts with the keyword 'title', followed by any string that describes that entry. Next are the 'kernel' entries. We've not worked with the BSD's, but the process of booting the BSD's is very well documented in the texinfo manual. For the moment, we’re sticking with Linux.

kernel (hd0,1)/vmlinuz root=/dev/hda3 hdc=ide-scsi

The line above is pretty self-explanatory but for GRUB's naming convention of your devices. Floppy drives become (fdx) and hard drives become (hdx) where 'x' is the number of the device. One thing to remember is that GRUB counts up from '0' and not '1'. hd0 represents the first hard drive and hd1 the second. All device names are enclosed within brackets. Further, hard drive partitions are specified with a comma separating the two. e.g - (hd0,1) means second partition on the first device. Similarly, (hd1,5) refers to the first logical partition on the second hard drive.

GRUB can read most filesystems, and in the above line we set it up so that GRUB looks for the kernel in (hd0,1), which is the second primary partition on the first hard drive and the file '/vmlinuz'. You will also have to give 'root=/dev/hda3' or wherever your root filesystem lies, otherwise the kernel will not be able to mount the root filesystem. After this, you can put in any parameters that you want to pass to the kernel. These parameters are specified, as they would be when using LILO.

The other entry you will see here for booting Windows. This entry is a little different. The root entry here points to the root partition (c:) of your DOS/Windows installation. The next entry sets the active flag on the partition. The final entry tells GRUB to grab the first sector of the partition -- booting the OS there.

This was the configuration of the most common dual-boot setup for GRUB. Now you have to install GRUB as your boot loader. Keep a LILO floppy or a rescue disk in hand before you do so.

grub-install /dev/hda

Login as root and run the command "grub". You will then be looking at the following

GRUB version 0.5.96.1 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename. ]

grub>

This is the grub prompt that we will use to install GRUB on the hard drive. There's one long and complicated command-line that we're going to use.

grub> install (hd0,1)/boot/grub/stage1 d (hd0) (hd0,1)/boot/grub/stage2 p (hd0,1)/boot/grub/menu.lst

GRUB is divided into 2 major stages: stage1 and stage2. Stage1 is the tiny code that is embedded into the MBR. Stage2 is the main component here and handles everything else after Stage1 transfers control to it at boot-up.

The relevant parts of the command-line here are the first parameter given after ‘install’. This should point to the location of stage1 on your hard drive. As you can see, we're using the full drive notation as well as pointing to a specific directory on the partition. This is possible because GRUB can read filesystems. The 'd' parameter means that Stage1 will look for the disk where Stage2 is installed. (hd0) is the location where GRUB will be installed to. Since we want to use it as our primary boot loader, this means that it will install to the MBR. You can also point it to the root partition of your filesystem. The next parameter is the location of Stage2. This is also specified in the same manner as for Stage1. Then comes 'p' followed by the location of the configuration file menu.lst.

One problem that could arise with the above notation is if /boot is a separate partition. Let’s say (hd0,1) (hda2), is being mounted as /boot on your system. (hd0,2) (hda3) is your root partition. The above installation would have to be modified to the one below. You cannot say (hd0,2)/boot/grub/stage1 because GRUB does not know that (hd0,1) is mounted as /boot on your system. In this case, you will have to point first to the partition that is mounted as /boot and then to the grub directory under it.

grub> install (hd0,1)/grub/stage1 d (hd0) (hd0,1)/boot/grub/stage2 p (hd0,1)/grub/menu.lst

Reboot and you will have a decent GRUB menu in your hands. In case of any configuration problems you can check the web site or the locally installed documentation. The manual pages are in texinfo format so use ‘info grub’ to get to the real detailed documentation (‘man grub’ will give you very basic information)."
Rating : 5


----------------------------------------------------------------------
QAId : 8097747
Asker : cindy_lens
Subject : uppercase to lowercase
Private : No

Question : Hi

My boss wants me to change all the image files from the upper case extension .GIF to lower case .gif

He also wants to change all the .GIF text in the .html files to .gif as well.

There are so many .GIF files and thousands of .html files on the site.
I know little about UNIX scripts. Please help.

Thank you
Cindy

Answer : You can use this in a script file to rename the files:

for i in `ls`
do
mv $i `echo $i | tr '[A-Z]' '[a-z]'`
done

Something along those lines will rename the files in all lowercase.

As for changing it within the HTML files the same type of thing as above will do it.

--
Paul Doherty
http://home.attbi.com/~bitbucket911
DOS/Windows Utilities

Rating : 4.8
Rating : 4.8


----------------------------------------------------------------------
QAId : 8103295
Asker : grafman
Subject : copying files
Private : No

Question : Paul,

I was reading your recent answer about copying files and, (this is worth 5 stars to you) When you copy files look into rsync. If you can make an ftp connection you can also rsync.

rsync works recursively and will also update directories by deleting files that aren't on the source.

It also has options that allow you to skip classes of files, directories, and update only if the destination file is older than the source.

rsync comes on all platforms and is free and pretty easy to use. It comes standard with linux, and I think its incdluded with solaris 8 and 9.

It also works on the same system. Its commonly used to move web sites out of a staging area to an external webserver, or to update CVS archives.

Good answers, keep up the good work.

Answer : Thanks for the info on rsync - that's a new one on me and sounds very useful!
Rating : 5
Rating : 5


----------------------------------------------------------------------
QAId : 8309317
Asker : cindy_lens
Subject : enterprise E250 RAID5
Private : No

Question : Hi,

My boss wants me to set up a RAID 5 on SUN Enterprise E250 with 6 disks. I have never done any RAID setup before and I am very confused. Please provide step by step instruction if you can on how to set this up. Any example is appreciated.
Thanks,
Cindy

Need More Information : That's a rather involved topic. If you'll tell me what you're using (Solstice DiskSuite, Veritas Volume Manager, etc) I may be able to point you to a good tutorial.

FUQuestion : I'm using disksuite 4.2.1

Answer : RAID 5 isn't too bad in DiskSuite - try this link:

http://slacksite.com/solaris/disksuite/moredisksuite.html

PowerUsers.info - Paul Doherty Askme Archive of Questions and Answers

Return to AskMe Archive Main Page

Return to Main PowerUsers.info Main Page