LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-26-2011, 11:55 AM   #1
cpatno
LQ Newbie
 
Registered: Jul 2011
Posts: 5

Rep: Reputation: 0
Need help writing a script


Hello group, I need help writing a script, I am sure this can be done as a bash script but if someone wanted to do this in ruby or perl that would work just fine.

What I need to do is take a list of file names from my database, I then need to search in a directory and see if that file actual exists there, if it does not exist I need to be informed somehow.

Thanks in advance.
 
Old 07-26-2011, 12:17 PM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
So what did you come up with till now?
 
0 members found this post helpful.
Old 07-26-2011, 12:47 PM   #3
cpatno
LQ Newbie
 
Registered: Jul 2011
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Wim Sturkenboom View Post
So what did you come up with till now?
I have no solution as of right now.
 
Old 07-26-2011, 01:11 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Bash scripting guides

Code:
function help() { echo "Bash scripting guides:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html 
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html 
http://www.gnu.org/software/bash/manual/html_node/index.html
http://www.grymoire.com/Unix/Sh.html
http://www.tldp.org/LDP/abs/html/ 
http://wooledge.org/mywiki/BashFAQ?action=show&redirect=BashFaq 
http://wooledge.org/mywiki/BashPitfalls"; }
 
Old 07-26-2011, 01:17 PM   #5
cpatno
LQ Newbie
 
Registered: Jul 2011
Posts: 5

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by unSpawn View Post
Code:
function help() { echo "Bash scripting guides:
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html 
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.html 
http://www.gnu.org/software/bash/manual/html_node/index.html
http://www.grymoire.com/Unix/Sh.html
http://www.tldp.org/LDP/abs/html/ 
http://wooledge.org/mywiki/BashFAQ?action=show&redirect=BashFaq 
http://wooledge.org/mywiki/BashPitfalls"; }
Seriously, you are going to RTFM me? It isn't like I asked how do I list all files in a directory, WTF. This is the newbie forum right?
 
0 members found this post helpful.
Old 07-26-2011, 01:33 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
To Wim Sturkenbooms question you responded you have nothing to show. Now he basically asked for any commands or (pseudo)code you tried, as that makes it easier for us to correct you, after all you asked for help and not somebody writing the script for you. Without any effort on your side it's hard to gauge what we should provide you with and hence I think it's prudent to start at the beginning.


Quote:
Originally Posted by cpatno View Post
WTF.
Friendly advice: you're new here. Be careful who you think you can say that kind of thing to.
*Also it seems you marked his post as "unhelpful". If that's gonna be your attitude towards responses then that needs change.

//Note to all: with posts #6 and #7 the OP has received enough nudges wrt how he should progress. Please no more replies in the same vein.

Last edited by unSpawn; 07-26-2011 at 01:37 PM. Reason: //More *is* more
 
Old 07-26-2011, 01:35 PM   #7
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,131
Blog Entries: 2

Rep: Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833
Yes, this is the newbie forum. That doesn't mean we will do your work. If you want to write a script read a tutorial about scripting. If you have questions about that you can ask here for further explanation, we will help you with that, but only if you show us that you will do something for yourself. If that isn't what you want feel free to ask for a paid programmer in the LQ Job Marketplace.
 
1 members found this post helpful.
Old 07-26-2011, 01:36 PM   #8
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
Hello cpatno, welcome to LQ,

note that we have rules here, one of them is that we will not do other people's homework.

We expect that you post some code you have already written for your script. And then if you ask "this does not work, can you help me", you will get help.

btw, nobody here has learned Linux only by asking other people to do his/her work/homework and please note that we are all volunteers, if you need professional help you may (for example) hire a freelancer.

To your question, you did not mention which database you're using, which language/tools you should/would use and so on. Do you have an idea by yourself how to write such a script?

Markus
 
Old 07-26-2011, 01:37 PM   #9
cpatno
LQ Newbie
 
Registered: Jul 2011
Posts: 5

Original Poster
Rep: Reputation: 0
I took Wim's question as "what have you been using up to this point" which is that I haven't. I have acquired this from someone who let this get out of hand so that is why I have nothing working at this point. To the question of what have I tried so far, I have been playing around with different things that I have googled but I have had no luck.
 
Old 07-26-2011, 01:39 PM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,332
Blog Entries: 55

Rep: Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533Reputation: 3533
Quote:
Originally Posted by cpatno View Post
I have been playing around with different things that I have googled but I have had no luck.
Cool. Just show us what you tried and where it failed.
 
Old 07-26-2011, 01:40 PM   #11
hf2046
Member
 
Registered: Mar 2011
Distribution: Slack64
Posts: 111

Rep: Reputation: 20
Quote:
Originally Posted by cpatno View Post
Seriously, you are going to RTFM me? It isn't like I asked how do I list all files in a directory, WTF. This is the newbie forum right?
You know the saying... give a man a fish, feed him for a day... etc., etc.

Quote:
Originally Posted by unSpawn
Cool. Just show us what you tried and where it failed.
Exactly.

Last edited by hf2046; 07-26-2011 at 01:41 PM.
 
Old 07-26-2011, 01:40 PM   #12
cpatno
LQ Newbie
 
Registered: Jul 2011
Posts: 5

Original Poster
Rep: Reputation: 0
I just don't have scripting experience, my expertise lies in other areas of IT. I know this would take someone all of 2 min to type out but while you guys ride around here on your high horses I will go elsewhere, thanks
 
0 members found this post helpful.
Old 07-26-2011, 01:43 PM   #13
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
What's wrong with learning? This is a really good tutorial:

http://linuxcommand.org/writing_shell_scripts.php

If you really, really don't want to read the whole thing, at least check out chapter 9, it says how to check if a file exists there.

One thing about bash scripting is that it has a lot or quirks that newbies don't know about, which causes them to write code that seems to work for their situation but can actually do bad things when given certain types of input. So for that reason, I think that everyone who will be writing a bash script should at least read this:

http://mywiki.wooledge.org/BashPitfalls
 
2 members found this post helpful.
Old 07-26-2011, 01:52 PM   #14
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
Quote:
Originally Posted by MTK358
So for that reason, I think that everyone who will be writing a bash script should at least read this:

http://mywiki.wooledge.org/BashPitfalls
@MTK358: an interesting link, thanks.

Markus

Last edited by markush; 07-26-2011 at 01:53 PM.
 
Old 07-26-2011, 01:57 PM   #15
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,131
Blog Entries: 2

Rep: Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833Reputation: 4833
Quote:
Originally Posted by cpatno View Post
I just don't have scripting experience, my expertise lies in other areas of IT. I know this would take someone all of 2 min to type out but while you guys ride around here on your high horses I will go elsewhere, thanks
If you have no experience in scripting and also don't want to learn it you should say that to your boss, so that he can assign that task to someone who has experience or the will to learn. It makes no sense at all to come up with a solution that you are 1. not able to understand and 2. not able to maintain, if any changes occur. Has nothing to do with high horses at all.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] writing a script kenny53067 Linux - Newbie 27 07-24-2011 11:59 AM
Need help for writing Script vikrambhimbar Linux - Software 2 03-05-2006 05:28 AM
Need help writing a script wswartz Linux - Software 3 04-28-2004 04:35 PM
Help Writing a script. teeth44 Programming 2 10-14-2003 01:00 PM
Writing a Script Nyc0n Linux - General 2 05-27-2002 08:21 PM


All times are GMT -5. The time now is 10:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration