User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 456,423 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,608 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser: Programming Forums
Views: 1360 | Replies: 1
Reply
Join Date: Apr 2007
Posts: 1
Reputation: PrabhuScript is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
PrabhuScript PrabhuScript is offline Offline
Newbie Poster

Help Shell script Help

  #1  
Apr 12th, 2007
Hi Experts

I've less idea abt unix shell script. my requirement is the shell script should take a input of a file name and shud check if that file name is present in the particular folder which is hardcoded. if not then wrtie the file there or if found write the fle in another location. is it possible to acheive this. ur help is highly appricicateed. pls copy fo mailprabhu@gmail.com for any good doc's on the same.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2007
Location: Bangalore, India
Posts: 535
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Rep Power: 4
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: Shell script Help

  #2  
Apr 16th, 2007
Read this.
This is what I'll tell you..
  1. #!/bin/sh
  2.  
  3. hardcoded_folder="xxx"
  4.  
  5. #expected args:
  6. # $1: Relative path of file to be checked. (relative to hardcoded path)
  7. # $2: Abs path of "another location"
  8. #
  9. function my_function()
  10. {
  11. f_2_check=$1
  12. another_location=$2
  13.  
  14. #if -f $hardcoded_folder/$f_2_check then
  15. #file found, so write to another location
  16. #copy $hardcoded_folder/$f_2_check another_location/$f_2_check
  17. #else
  18. #file not found, so create it
  19. #touch $hardcoded_folder/$f_2_check
  20. }
  21.  
  22. my_function file_2_check /another_location
Last edited by thekashyap : Apr 16th, 2007 at 9:39 am.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Shell Scripting Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 1:08 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC