- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- read only cat
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 06:17 AM
06-13-2003 06:17 AM
cat > myfile, will flush the contents of myfile.
Is there anything other than more, more does'nt cut it as it stops when the terminal X limit.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 06:22 AM
06-13-2003 06:22 AM
Re: read only cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 06:24 AM
06-13-2003 06:24 AM
Re: read only cat
for $i in filename
do
echo $i
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 06:25 AM
06-13-2003 06:25 AM
Re: read only cat
the problem in not with cat but with myfile.
if you use that command, and you can trim the file, it's a choice of yours.
If you want a command to view the content of the file, just use "view FILENAME", it should do the work.
There are other commands, like "page", if you want read-only mode.
If the problem is the terminal, ou must first specify which kind of terminal you have, woth a sintax like
"export TERM=xterm"
and then
"resize"
HTH,
Massimo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 06:27 AM
06-13-2003 06:27 AM
Solutioncat > myfile
will not overwrite myfile
you could also use grep
grep . myfile
this will display the contents of myfile
however if you redirect any output using > to a file it will overwrite it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 06:27 AM
06-13-2003 06:27 AM
Re: read only cat
view the file
cat file
append to the file
cat >> file
clear the file
> file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 06:28 AM
06-13-2003 06:28 AM
Re: read only cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 06:34 AM
06-13-2003 06:34 AM
Re: read only cat
tee -a myfile will echo stdin to stdout and append the stdin to myfile. You can actually see what you are doing with this command. Man tee for details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 06:44 AM
06-13-2003 06:44 AM
Re: read only cat
The "grep .
maybe my question was to poetic.
but I want to remsh in to a bunch of machines and send the contents of any file to STDOUT.
cat is way too dangerous.
peace
Donny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 06:45 AM
06-13-2003 06:45 AM
Re: read only cat
If you are interested in protecting your file from inadvertant overwrite, you can set the "noclobber" option. See the man pages for 'sh_posix' for more details.
Consider:
#!/usr/bin/sh
exec 2> /dev/null
trap 'echo Attempted overwrite denied' ERR
echo "bang! at `date`" > /tmp/mylog
exit 0
Call the script "my.sh" and run it like:
# ./my.sh
Now run it with the 'noclobber' option:
# sh -C ./my.sh
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 07:21 AM
06-13-2003 07:21 AM
Re: read only cat
Cat simply 'concatenates' a file. Your redirection is what can be dangerous. Whether you use cat or your grep ., if you want to save STDOUT into a file, you still need to redirect the output!
remsh host "cat file"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 07:59 AM
06-13-2003 07:59 AM
Re: read only cat
remsh cpu1 cat /etc/passwd > /var/tmp/pw
remsh cpu1 cat /etc/passwd \> /var/tmp/pw
This will list the contents of /etc/passwd from the remote system called cpu1 and place in the local file /var/tmp/pw. The second line, however, will copy the file inside the remote server and the copy stays on the remote server. There is only one character different and that is the escape for >. The shell sees > and interprets it as a redirection symbol. With \>, the shell is told to ignore the redirection and the entire string is sent to the remote system.
It sounds like you need to write specific scripts to accomplish the needed tasks and debug how the data is being redirected. grep or any other command is just as dangerous as cat when you don't get redirection properly defined.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 10:29 AM
06-13-2003 10:29 AM
Re: read only cat
however been burnt before with remsh and executing the most obvious commands such as
for x in serv1 serv2 ... serv100
do
echo $x
remsh $x "cp /etc/passwd /tmp/passwrd.orig"
done
from anyones viewpoint this is a strait forward copy.
however for some unknown reason 10 of the boxes lost the password contents - and no-one could explain why.
one bitten twice shy
peace
Donny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 11:11 AM
06-13-2003 11:11 AM
Re: read only cat
You may want to log all input/output/error of your commands
remsh $x 'cp passwd passwd.orig > /tmp/cp.log 2>&1' or something to that effect
Or like Bill mentioned, log all STDOUT and ERR to a local log file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2003 03:57 PM
06-13-2003 03:57 PM
Re: read only cat
anyway, thanx for the advise. personnaly I like the grep method.
peace
Donny