creating directory from scripts


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting creating directory from scripts
# 1  
Old 08-22-2012
creating directory from scripts

Dear All,

I have a shell scripts which create a directory and perform moving some files, when the script is kept where it is creating directory then it runs fine , but when the scripts is run where it is supposed to be which is different location then where i am creating directory , scripts faild to create directory
Code:
 NEWDIR=RIO_`date +%d-%b-%Y`
 mkdir /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/$NEWDIR
 cd /var/opt/ers/logs/rio
 touch -t `date +%Y%m%d0000` dummy
 find . -newer dummy -type f  |
 while read fname
 do
     mv $fname /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/$NEWDIR
 done
 cd /ersdg3/ERS/ERS_INPUT_LOGS/RIO/LOGS/$NEWDIR
 for i in *.LOG
 do
 wc -l $i | awk '{ print $1"|"$2 }'
 done>RIO_AUDIT_REC.TXT

when the scripts is kept at /ersdg3/ERS/ERS_INPUT_LOGS/RIO it funs fine for the 2nd line of code, but when the scripts location changed to /ersdg3/ERS/ERS_INPUT_LOGS/loader it says can't create directory.

any clue
# 2  
Old 08-22-2012
Insert echo after mv
Code:
echo $fname

find find also files from subdirectories. Maybe need option -maxdepth 1
# 3  
Old 08-22-2012
Quote:
Originally Posted by kshji
Insert echo after mv
Code:
echo $fname

find find also files from subdirectories. Maybe need option -maxdepth 1
i have a problem in 2nd line of code where it create directory, if i am creating a directory where the scripts is also lying then works, but when the scripts is kept at different place then it is unable to create directory
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with creating startup scripts using screen

Edit: So sorry! I really didn't do a good job of clearly stating what I needed. Going to completely rewrite my post so everything is clearly stated. I'm having trouble writing a shell startup script for a linux server. It uses the bash shell if I remember correctly. I'm trying to write it so... (9 Replies)
Discussion started by: Pyitoechito
9 Replies

2. UNIX for Dummies Questions & Answers

creating file and it directory

hello, is there any command that i can use to create a file and also it directory (if not exist)? example: <command> /home/admin/testdir/test1.txt desc: this will create test1.txt under testdir directory. but if testdir is not exist it will be created automatically. thank you... (3 Replies)
Discussion started by: makan
3 Replies

3. UNIX Desktop Questions & Answers

creating an executable file from shell scripts

Hi Friends, I have a shell script which does some operations etc, would it be possible to create an executable file out from this shell script? meaning the executable file is not editable, thus the source code will not be visible to other users for copyright reasons. Please help, thanks! (1 Reply)
Discussion started by: kokoro
1 Replies

4. UNIX for Dummies Questions & Answers

Need help in creating directory

Hello Experts let say we got a line a file named /user/Oracle/my_catalog/default/root/webcat+backup+testing+07192011.atr now i have to create a directory with name webcat backup testing 07192011 by removing + and removing .atr at the given path...can it be possible Please let me know... (4 Replies)
Discussion started by: aks_1902
4 Replies

5. Shell Programming and Scripting

Creating Directory

Hi All, As I m very new for Unix, I need to check for a directory and move a file. If Directory is not found, The script should create a directory and move the file. Can any one help here. (7 Replies)
Discussion started by: vikramtk
7 Replies

6. Shell Programming and Scripting

Creating Log files from Scripts

Hi I would like to create a log file to track the execution of my script. Example, if there were any errors, if it passed or failed etc. How do I go about doing this. My log file will be saved to this location: /var/log/import.log How do I specify the directory? I have been... (1 Reply)
Discussion started by: ladyAnne
1 Replies

7. Ubuntu

Problem creating Desktop shortcuts through Debian dpkg installer scripts

Hi, I am creating a debian package (*.deb) for my application using the command I am using debian pre/post installer scripts to do certain tasks before/after installation/uninstallation. One such task is to create a shortcut on the user's desktop to launch my application. I am trying to do this... (0 Replies)
Discussion started by: royalibrahim
0 Replies

8. Shell Programming and Scripting

creating scripts

Hello... First of all, as a new member, i found this forum very helpful and all the members have great knowledge. I am trying to learn unix online, as i have to make a script to monitor a solaris machine performance. I found UNIX not as hard as i thought but making scripts and printing it... (5 Replies)
Discussion started by: mohamedh_14
5 Replies

9. Shell Programming and Scripting

Creating date directory and moving files into that directory

I have list of files named file_username_051208_025233.log. Here 051208 is the date and 025233 is the time.I have to run thousands of files daily.I want to put all the files depending on the date of running into a date directory.Suppose if we run files today they should put into 05:Dec:08... (3 Replies)
Discussion started by: ravi030
3 Replies

10. UNIX for Advanced & Expert Users

creating directory error

i have create a Directory with "$@#$%" . After creating a Directory, put ls command display "#$%" . Why? (2 Replies)
Discussion started by: lakshmananindia
2 Replies
Login or Register to Ask a Question