LinuxQuestions.org
Register a domain and help support LQ
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 02-22-2012, 11:07 AM   #1
arsh gill
LQ Newbie
 
Registered: Feb 2012
Posts: 4

Rep: Reputation: Disabled
WANTED HELP IN SCRIPT writing


a script which will print "foo" when the input is "bar" and print "bar" when input is "foo"
 
Old 02-22-2012, 11:12 AM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
If you'll be writing your script on a Linux system, bash would be a good candidate for your simple problem. I recommend taking the time to read:

http://www.tldp.org/LDP/abs/html/

If you run into problems, post what you've tried, and LQ members can offer suggestions.
 
1 members found this post helpful.
Old 02-22-2012, 12:00 PM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,254

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
Show us your efforts and we will help.
 
1 members found this post helpful.
Old 02-22-2012, 08:24 PM   #4
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,053

Rep: Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881Reputation: 881
There was another question, maybe a month or two back, that was very similar (it involved foo and bar, and a little extra complication...but then, so many questions seem to involve those two - foo and bar - that it isn't the easiest thing in the world to search on), so I wonder if maybe you and the other poster are at the same educational institution?

In any case, this being a program, you'll want to structure it, so you might want to start by posting the pseudocode you've come up with so far. You might not normally formally write pseudocode for a program this simple, but posting a flow chart would probably be a pain, and I'm not sure how else you'll be showing the rest of the world what you currently have in mind.
 
Old 02-22-2012, 09:05 PM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,825

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
Quote:
a script which will print "foo" when the input is "bar" and print "bar" when input is "foo"
WTF ?????

is there a question here?

from the other 3 posts this is homework
please BAN the user

Last edited by John VV; 02-22-2012 at 09:07 PM.
 
Old 02-23-2012, 02:45 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Per the LQ Rules, please do not post homework assignments verbatim. We're happy to assist if you have specific questions or have hit a stumbling point, however. Let us know what you've already tried and what references you have used (including class notes, books, and Google searches) and we'll do our best to help. Also, keep in mind that your instructor might also be an LQ member.
 
Old 02-23-2012, 02:49 AM   #7
cbtshare
Member
 
Registered: Jul 2009
Posts: 610

Rep: Reputation: 42
yes its actually a question.It was asked in the forum already and answered.Look up variable substitution and you'll be on the right track..
 
Old 02-23-2012, 11:59 AM   #8
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
I'm not going to link to it at this time, but you're probably all thinking of the thread where I posted an unconventional solution to a very similar problem. It wasn't foo and bar though, and the complication was that there was also a default value that needed to be printed if no input was given.

I don't think anyone ever actually posted a more conventional solution in that thread, but this is such a basic-level scripting problem that even a cursory reading of any scripting guide should be enough to solve it.
 
1 members found this post helpful.
  


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
script wanted ust Linux - Newbie 2 06-12-2009 12:46 AM
Writing a poweroff script ,wanted to know where i can find the necessary info! wrapster Solaris / OpenSolaris 6 06-22-2008 02:51 PM
NS2 Script wanted. Will pay :D zeeshan12 Linux - Networking 2 06-09-2008 09:40 AM
WANTED: rc.firewall - the script! Sjonnie48 Linux - General 4 01-16-2008 10:46 AM
script wanted ust Linux - General 2 09-03-2003 02:20 PM


All times are GMT -5. The time now is 01:04 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