Using ls in a script for another directory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Using ls in a script for another directory
# 8  
Old 06-05-2003
Works as follows on Solaris 8 (and 2.6) in ksh as follows:

$ cat jag
#!/bin/ksh
cd /home/myhome/test
ls -ls *.fixed
exit

$ ./jag
0 -rw-r--r-- 1 justmer sysadmin 0 Jun 5 15:57 EVENMORE.LOG.fixed
0 -rw-r--r-- 1 justme sysadmin 0 Jun 5 15:50 junk.fixed
0 -rw-r--r-- 1 justme sysadmin 0 Jun 5 15:56 more.log.fixed

You might want to post the code you have in the script (and any variables).
# 9  
Old 06-05-2003
It looks like your script is interpreting *.fixed literally... check to make sure you're not using something like ls '*.fixed' with apostrophes.. and while you're at it check capitalization.
# 10  
Old 06-05-2003
Create a file called perderabo.fixed and put it in the target directory. Change your shell script to display only that file. Does this much work?

If so, do the command:
set -o | grep noglob

Do you see:
noglob &nbsp &nbsp &nbsp &nbsp &nbsp &nbsp off

This could be caused by turning noglob on. Don't do that.
# 11  
Old 06-05-2003
In a new script file I have put;

#!/bin/ksh

cd /app/icop/aircrews/CIP/data/CMSLOG/log/batch/history
PWDIR=`pwd`
cd $PWDIR
ls -ls *.fixed

echo ""
cd /app/icop/aircrews/CIP/data/CMSLOG/log/batch/history
ls -ls *.fixed
exit

Output =
/home/users/thripj $testls
8 -rw-r--r-- 1 icopmgr icop 1318 Jun 4 15:05 ADDR0605003136.LOG.fixed

8 -rw-r--r-- 1 icopmgr icop 1318 Jun 4 15:05 ADDR0605003136.LOG.fixed

I put the code into my original script and get
*.fixed: No such file or directory

*.fixed: No such file or directory
/home/users/thripj $
I am a bit reluctant to put my code in this forum, because the system I am dealing with has very sensitive data.
Plus there are a lot of lines of code in this script.
# 12  
Old 06-05-2003
I have tested the viewing of files in a seperate script, which works I might add.

/home/users/thripj $set -o | grep noglob
noglob off
/home/users/thripj $
# 13  
Old 06-05-2003
Well, so you know that your code / environment settings / etc are all set properly to display what you want to display ... there's something wrong with your script, but if you feel it's too sensitive, it's hard to help... at the very least, is it still too risky to display the block of code in your script that actually changes to the directory with the *.fixed files in them and displays them? You wouldn't have to display the whole script..
# 14  
Old 06-05-2003
Well, you know the problem is in your script. Maybe you can get another SysAdmin to look at it (at your office) if you can't/won't post the script.

Take a break or leave it for tomorrow(and in the middle of the night you will probably figure it out). Also, you could change anything you believe you need to for security reasons. If you think my home directory is myhome and my user ID is justme....
It is common to insure you don't put something out here that may show where someone might be able to get into. If you did, some of us would probably notice and let you know to change it. I called and emailed one person (female) who left their email and phone number on one of their questions (at the time I was not a moderator so I couldn't edit it). She was shocked that I knew her number. I told her to change the post immediately. She deleted it and never did get an answer to her problem. You just have to be careful.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

2. Shell Programming and Scripting

What is the function of the following lines at the top of a shell script file: Directory and Script?

The file starts like this: Directory: <path to the script> Script: <script fife name> #!bin/ksh ##Comments <actual script> What is the use of the first two lines in the script? What if I save the file without them? What will be the effect? They are not comments. Im very new to this,... (4 Replies)
Discussion started by: remytom
4 Replies

3. Shell Programming and Scripting

Moving Files one directory to another directory shell script

Hi, Could you please assist how to move the gz files which are older than the 90 days from one folder to another folder ,before that it need to check the file system named "nfs" if size is less than 90 or not. If size is above 90 then it shouldn't perform file move and exit the script throwing... (4 Replies)
Discussion started by: venkat918
4 Replies

4. Shell Programming and Scripting

Shell scripting-I need a script which should watch a directory for a file with specific directory

I need a script which should watch a directory for a file with specific directory. If it finds a file in directory, it should search for few specific keyword in the file. if the keyword exists, it should trim string from specific column. The file should be moved to another directory and the a... (8 Replies)
Discussion started by: akashdeepak
8 Replies

5. Shell Programming and Scripting

Script which removes files from the first directory if there is a file in the second directory

Script must removes files from the first directory if there is a file with same name in the second directory Script passed to the two directories, it lies with them in one directory: sh script_name dir1 dir2 This is my version, but it does not work :wall: set - $2/* for i do set -... (6 Replies)
Discussion started by: SLAMUL
6 Replies

6. Shell Programming and Scripting

script that reads all the scripts in the directory and run them within that script

Hi I am trying to write a shell script that is reading all the scripts in the current directory (currently 5) and is allowing me to run the scripts that is in the directory. I want that this scripts asks te user to execute 1 of the listed scripts. I have 4 sample scripts in the directory:... (8 Replies)
Discussion started by: I-1
8 Replies

7. Shell Programming and Scripting

Run script from the directory it is in

I have a script at /java/custom/build.sh I want to force the user to execute the script from the /java/custom directory ONLY. In other words if the user is in /java I want to exit if they execute custom/build.sh The directory structure may change from the env to env, so I can't use... (4 Replies)
Discussion started by: t_c_1980
4 Replies

8. UNIX for Dummies Questions & Answers

Script to find a string in a directory/sub-directory

I'm trying to find this string 'preparing string IBE_Quote_W1_Pvt.SaveWrapper for quote_header_id’ in my Apache log file directory. The log file that contains this string may be in a parent direcotry or a sub-directory. I have tried 'grep' and 'awk' with no success. I would like to get the path... (3 Replies)
Discussion started by: gross
3 Replies

9. Shell Programming and Scripting

Executing script's directory

I have a shell script /home/user1/bin/sh1, how can I print out the directory of this file inside the script. Say I am in /home/user1/, then I run /home/user1/bin/sh1 I need it to print out /home/user1/bin. Thanks. (2 Replies)
Discussion started by: jasony001
2 Replies

10. Solaris

running script in any directory

hi im a cobol programmer but im new in unix. I just want to know how can i run script even if it is in other directory?? Thanks, (1 Reply)
Discussion started by: shinjeck
1 Replies
Login or Register to Ask a Question