Beginner in ksh - umask query


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Beginner in ksh - umask query
# 1  
Old 07-25-2012
Beginner in ksh - umask query

I started to learn KSH

I am doing some exercises from the book
Code:
$ umask =rx, u+w                                       
$ print Keep track of everythine > file1.out           
$ print Be careful >> file1.out                        
ksh: file1.out: cannot create [Permission denied]
$ umask -S                                             
u=,g=,o=
$ set -o | tee tee.out | grep ignoreeof                
ignoreeof                off
$ grep monitor < tee.out                               
ksh: tee.out: cannot open [Permission denied]
$ print ~me | grep me | cat >> file1.out         
ksh: file1.out: cannot create [Permission denied]
$ print *.out                                          
file1.out tee.out
$ /usr/bin/grep track *.out | wc                       
grep: can't open file1.out
grep: can't open tee.out
       0       0       0
$ grep track < f*out | wc                              
ksh: file1.out: cannot open [Permission denied]
       0       0       0
$ time sleep 20 > /dev/null 2>&1                       

real    0m20.02s
user    0m0.00s
sys    0m0.00s

I see I can do much with files I created because of umask is set to 022. But interesting is I can create new files (example with tee command). Why I can do this if my umask is 022 ?
# 2  
Old 07-25-2012
Your second umask command unset all permissions! The command was interprested as umask = and the rest of the line was ignored. Thus the file was created with permissions 000 . From that point on only the root user could write to that file.

Code:
umask -S
u=rwx,g=rx,o=rx

umask =  
umask -S
u=,g=,o=

Try looking at the directory with ls -la and learn to understand the first column (permissions).


When adjusting umask , the parameters are like u=rw (and many other variations). See man umask and thence man chmod for the full explanation.

Last edited by methyl; 07-25-2012 at 09:57 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Asign to variable ksh some values of sql query

Hi, I'm trying to asign to ksh varible some values of a sql query. The output query would be: xxxx 1 yyyy 2 I do: values=`$PATH_UTI/query_sh " select think1||'------'||think2 from some_table where think3 = '$1'; ... (2 Replies)
Discussion started by: mierdatuti
2 Replies

2. UNIX for Dummies Questions & Answers

Extract only the data from ksh script running netezza query

Hi I searched this forum before posting the question, but couldnt find it, the issue i'm facing is, i'm trying to select a column from a netezza table from a korn shell script, but the query runs var=$(nzodbcsql -q "select MAX(millcount) from table1";) echo $var it returns the value like... (10 Replies)
Discussion started by: maximus_jack
10 Replies

3. Shell Programming and Scripting

Shell Script (ksh) - SQLPlus query filter using a string variable

Using ksh, I am using SQLPlus to execute a query with a filter using a string variable. REPO_DB=DEV1 FOLDER_NM='U_nmalencia' FOLDER_CHECK=$(sqlplus -s /nolog <<EOF CONNECT user/pswd_select@${REPO_DB} set echo off heading off feedback off select subj_name from subject where... (5 Replies)
Discussion started by: nkm0brm
5 Replies

4. Programming

Shell programming ksh AIX - beginner

Hi! I have two shell scripts - Script1, Script2 Script1, Script2 - have return parameter Script1 - is calling Script2 in Script2 I am calling program sqlldr - if this program is called then I did not get the return parameter from Script1 Do You have any idea how can I avoid this problem. Mroki (6 Replies)
Discussion started by: mroki
6 Replies

5. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

6. Shell Programming and Scripting

to find whether update query is successfull or not using Ksh Script

i have a script that performes an update operation. I just wanted to know whether that update statement is successfull or not. Below the script: #!/bin/ksh . $HOME/conf/systemProperties/EnvSetup.properties sqlplus -silent sie/da@edn.world <<END set pagesize 0 feedback off verify off... (3 Replies)
Discussion started by: ali560045
3 Replies

7. UNIX for Dummies Questions & Answers

Query a DB from another DB in ksh

I'm trying to connect to a DB on a windows server from a DB on a unix server. While I can connect, I can't seem to get the expected results back, I'm only getting the number "2" back no matter what date I put in (I should be getting "408" or "410" depending on the date). Funny, when I go into... (1 Reply)
Discussion started by: tekster757
1 Replies

8. Shell Programming and Scripting

Query regarding ksh

I wrote a script in ksh as follow: echo "Hello" if ; then echo "bye" else echo "Welcome" fi i ran this script two time with different syntax like this: ~/my_temp > ./test.ksh Hello bye ~/my_temp > test.ksh WIDTH: 12 WIDTH: 17 RELEASE (4 Replies)
Discussion started by: vaibhav
4 Replies

9. Shell Programming and Scripting

passing result of query to a varibale in ksh script

Hi, I have a scenario where in i have to extarct max of one column and pass it to a variable. i have tried to export the result as .dat file and read from that file.But my database is mainframe and it is not permitting me to export in .dat file.I have tried using .ixf file but reading from... (2 Replies)
Discussion started by: ammu
2 Replies

10. Shell Programming and Scripting

KSH n FTP query

Hi, I have this slightly modified FTP code (thanks to this forum) function gather_FTPDate { HOST= USER= PASSWD= exec 4>${TEMP_LOG_FILE} ftp -nv >&4 2>&4 |& echo $? if ] then echo "Unable to connect to FTP server!!!" >> ${LOG_FILE} return 0 fi print -p open... (2 Replies)
Discussion started by: psynaps3
2 Replies
Login or Register to Ask a Question