April 16, 2014, 10:13:55 AM

News : LinuxSolved.com Linux Help Community Forum..


Recent Posts

Pages: 1 ... 8 9 [10]
91
Linux Development & Programming / Shell Scripting Help
« Last post by Chris4610 on November 09, 2012, 04:18:02 AM »
Hello Everyone,

    I am looking for help in figuring out exactly what I need to do and if someone can help me figure it out, it would get me out of a huge jam. I am including what i'm being asked to do and will show an example I was given, I was told that the example could be altered to do what is asked below, I just don't understand this script stuff at all.

Ty,

Chris

Case – switch 2,  9 points (3 if it runs correctly, 5 if all components are included and 1 for
comments) and yes we live in a partial credit world.   
This project is an extension of the case and switch assignment from last week.  We have
used all the elements of this script in prior homework projects, puzzles and/or scripts. 
This time around everything is a choice in a case switch script.   
Your shell script will use case and switch and should include the following elements:
some kind of conditional test to proceed (date, verify users is logged, etc)
request the user’s name (save as a variable to be used at exit)
a counter that counts the number of total choices made by the user
a use of the cut command (cut a field from you friends list or some other file)
an option to run 5 different commands (ls, who, ping etc) and 
on exiting the script, echo the user’s name, user inputs (you will want to save
these as varialbes and how many choices the user made).   
Comments MUST be included in the script!  Your script should be easy for anyone to run
without the need of prompting from you, the developer.
Email a copy and leave an executable copy in the appropriate homework directory.
Remember, by reading your comments I should be able to see exactly what your script is
doing (or suppose to do).  Why use comments?  Comments force you to think through the
scripting process.  Scripting could be considered a mechanical process of converting your
comments into UNIX commands.
*** READ the following paragraph to help you with your puzzle!! 
Trouble shooting your script (in case you need it)….  This script has more elements and
more potential to bonk, crash, not work.  What you should do is start with the BASIC C-S
script and start adding elements to the known to work script.  If the script bonks and
before you declare yourself “lost”(remember lost is a television show!), comment out newly
added lines until the script works again.  Now you have a block of code that needs to be
carefully reviewed.  If we were sitting in a face-to-face class this is exactly the process we
[YOU] would be asked to do.  Start with a simple script (the frame work from last week is
a good starting point) and develop it from there, don’t forget to make copies of your work
along the way!!

#! /bin/csh
echo "Enter the month date"
set a = ($<)  frugard
set date = `date | cut -f 3 -d ' '`     #date command cut to the date
        if ( $a == $date ) then         #if correct date entered
        echo "What's your first name ?" #ask for name
        set b = $<                      #setting variable
        echo "Hello $b "
        else
        echo "I'm sorry that is not correct."
        exit 0
        endif
        @ h = 0                         # declaring the variables
        @ i = 0
        @ j = 0
        @ k = 0
        @ l = 0
        @ z = 0
set e = /home/fall_05/user-name/HW/11-22  #path
set f = $e/menu                         #set variable for menu
while (1)
        top:
        clear
        cat $f                          #cat menu
        echo -n "Enter your choice  "
        set a = $<                      #set variable for choice
        #set z = 1                      # the counter wouldn't work until I defined the
variable
        switch ( $a )
                case [aA]:              #case a
                        @ h = 1         # h is equal to 1 this sets the variable
 for listing inputs
                        ls              #command
                        @ z = $z + 1    #The counter
                        sleep 2
          goto top
                case [bB]:
          @ i = 1
                        who
                        @ z = $z + 1
                        sleep 2
          goto top
  case [cC]:
          @ j = 1              last |grep $b |wc -l
                        @ z = $z + 1
                        sleep 2
          goto top
                case [dD]:
          @ k = 1
          finger
                        @ z = $z + 1
          sleep 2
          goto top
                case [eE]:
          @ l = 1
                        @ z = $z + 1
                        echo "Thank you $b for entering $z choices."
                        echo "You ran the following commands "
                                if ( $h == 1 ) then
    echo "ls "              # if h is equal to 1 then echo ls and so
forth following down the line
                                if ( $i == 1 ) then
                                echo "who "
                                endif
                                if ( $j == 1 ) then
                                echo "last "
endif
                                if ( $k == 1 ) then
                                echo "finger "
                                endif
                                if ( $l == 1 ) then
                                echo "exit "
                                endif
        exit 0
                endsw       # end switch
end                     # end while statement #! /bin/csh
#case switch
echo -n "Please enter your name... " #prompts user for name
set name=$<     #sets user input to variable
@ i = 0         #counter begins at zero
@ a = 0
@ new = 0
@ f = 0
@ c = 0
@ n = 0
@ z = 0
@ dir = 0
@ address = 0
while (1)       #while true
echo $i         #counter
clear           #clear screen
top:            #place holder for goto
cat options     #look at option file
@ i = $i + 1    #increment counter at each pass
echo options    #echo options to screen
echo -n "Enter your option... " #prompts user for selection
set z=$<                        #sets user input to variable
switch ($z)
echo ""                         #inserts a blank line
        case [aA]               #chosen if user selects option aA
clear
        echo -n "Which file would you like to copy? " #prompts user for input
        set a=$<                #sets user input to variable
        echo -n "What is the new filename? "    #prompts user for input
        set new=$<              #sets user input to variable
        cp $a $new              #copies one file to another
        echo -n file $a was copied to $new  #displays the file names
        echo ""                 #inserts a blank line
        goto top                #return to the top and start over
        case [bB]               #chosen if user selects option bB
        clear
        echo -n "Which file would you like displayed? " #prompts user for file n
ame
        set f=$<                #sets user input to variable
        if (-e $f) then         #if the file exists then
        cat $f                  #cat the file
        endif       #end if statement
        echo ""                 #inserts a blank line
        echo -n "Which column would you like to cut? "  #prompts user for column
 to cut         set c=$<                #sets user input to variable
        cat $f|tr -s ' ' | cut -f $c -d ' '>duh2 #looks at file, removes spaces,
 cuts field and saves as new file
        echo ""                 #inserts a blank line
        cat duh2                #look at the edited file
        echo ""                 #inserts a blank line
        goto top                #return to the top and start over
        case [cC]               #chosen if user selects option cC
clear
        echo -n "Enter the name of the file that you'd like to look at. " #promp
ts user for input
        echo ""                 #inserts a blank line
        set f=$<                #sets user input to variable
        cat $f                  #performs cat on user input
        goto top                #return to the top and start over
        case [dD]               #chosen if user selects option dD
        clear                   #clear screen
        loop:                   #place holder
        cat options1            #look at the options1 file for additional option
s
        echo options1           #echo the options to the screen
        echo -n "Which function would you like to perform? "
        set i=$<                #sets user input to variable
        switch ($i)
                case [1]
                clear
                echo -n "Which directory would you like to look at? " #ls comman
d, prompts for directory
                set dir=$<      #sets user input to variable.
                ls -alF $dir    #performs ls on directory from user input
                echo ""         #inserts a blank line
                goto loop       #go to loop placeholder
                case [2]
                clear
                echo ""         #inserts a blank line
who             #performs who
                echo ""         #inserts a blank line
                goto loop       #go to loop placeholder
                case [3]
                echo ""         #inserts a blank line
                echo -n "What is the address to ping? " #prompts user for addres
s to ping
                set address=$<  #sets user input to variable
                ping $address -c 1      #performs ping, on user input, for one c
ount
                echo ""         #inserts a blank line                 goto loop       #go to placeholder
                case [4]
                clear
                echo "Who would you like to 'finger'?" #prompts user for name
                set n=$<        #sets user input to variable
                finger $n       #performs finger on variable
                echo ""         #inserts a blank line
                goto loop       #go to placeholder
                case [5]
                goto top        #go to placeholder
        endsw                   #end switch
                case [eE]       #chosen if user selects option eE
        echo -n "You entered option e, to exit. Goodbye $name! $i options were c
hosen. Your inputs were $z, $a, $new, $f, $c, $n, $dir, $address. "          #ec
ho the user's name, how many choices were made and what the inputs were.
                                #displays which option was entered and exits the
echo ""                 #inserts a blank line
        exit                    #exit
        breaksw                 #ends
endsw                           #end the switch
end                             #end the while statement

92
Linux Development & Programming / Programming Help
« Last post by Chris4610 on November 09, 2012, 04:12:06 AM »
Hello,

    I am in need of some help with several programming questions, I am truly lost so if someone can please help me i'd be greatful.

Ty,

Chris

1. Declare a function that is called Compute_Avg. The function returns a float data, receives an integer parameter named “num”, and a float parameter named “Average”.

2.  x = 2, y =1, z =3, what is the value of x, y, z after executing the following codes?
   switch(x)
   {   
      case 0: x =2; y =3;
      case 1: x =3; break;
      default: x=3; y=2 ;
   }

3.  Find any errors in the following function declarations.
   a. int sun(int x, y);
   b. int sun(int x, int y)
   c. void sun(void, void) ;
   d void sun(x int, y float);

4.   What is the output of the code corresponding to the following pseudocode?
   (a)
 X = -5;
if  (X > 0)
   printf(“%d”,X);
if (!((X=0) && (X<0)))
   printf(“Not”);

(b)
      #include<stdio.h>
      #include<stdlib.h>
void print_message(void);
int main()
{
   print_message( );
   printf(“This is a new message.\n”);
   print_message( );
   print_message( );
   printf(“The end.\n”);
   system(“pause”);
   return 0;
}
void print_message( )
{
      printf(“Hello !\n”);
      return;
}


5. If num=5, determine whether each of the following expressions is true or false.
a.   (num*num)>=(2*num)
b.   (3*num-2)<=6


6.  A home mortgage authority requires a deposit on a home loan according to the following schedule:
   Loan$                  Deposit
   Less than $25000            6% of loan value
   $25000-$49000            $1000+10% of loan
   $49000-$100000            $2000+25% of loan
Loans in excess of $100000 are not allowed. Write a program that will read a loan amount and compute and print the required deposit.




7 Write a program that inputs one number, then display “yes” if num = 1, display “no” if num =2, displays “maybe” if num = 3, display “Error message” if num is not 1,2 or 3. Implement this program by a Switch statement.



8.  Write a function float Average(int, int, int, int) that finds the average of four numbers, and then write a main program that inputs four numbers from the user. You need to call the function and display the mean of the four numbers in the main.


The cost of renting a tool is $20 for the first day, $10 per day for the next 3 days and $8 per day thereafter. If the input is the number of days the tool was rented, compute the cost of renting the tool.


93
Os Talk / resolve the disk failiure
« Last post by kalaiselvan on November 07, 2012, 05:54:34 PM »
when i start the ubuntu machine it through the disk failiure error how can i trobleshoot that this kind of problem
94
Linux Kernel / Re: Linux sound. What to set in kernel. Why not buitlin / why module?
« Last post by dalek on November 03, 2012, 12:57:00 AM »
When I get a new system, or build one, I use this site to figure out what drivers I need for hardware:

http://kmuto.jp/debian/hcl/

There are two ways to work this.  Paste the results of lspci -n in the box or use the left side and look up by manufacturer.  First is the best if you have the system and second is best if you are looking to buy or build one. 

Hope that helps. 

 :)   :)
95
Linux Kernel / Linux sound. What to set in kernel. Why not buitlin / why module?
« Last post by xcislav on November 02, 2012, 04:40:41 PM »
What's the minimal in kernel?

alsaconf :
No supported PnP or PCI card found
Probe legacy - no legacy.

Code: [Select]
make menuconfig
Device Drivers > Sound card support * >
Preclaim OSS device numbers *
<*>   Advanced Linux Sound Architecture  --->

<*>   OSS Mixer API                                                         │ │ 
  │ │      <*>   OSS PCM (digital audio) API                                           │ │ 
  │ │      [*]     OSS PCM (digital audio) API - Include plugin system

 [*]   PCI sound devices  --->
<*>   (Creative) Ensoniq AudioPCI 1371/1373

What to set inside
Code: [Select]
< >   Intel HD Audio  --->
│ │      (64)  Pre-allocated buffer size for HD-audio driver (NEW)                   │ │ 
  │ │      [ ]   Build hwdep interface for HD-audio driver (NEW)                       │ │ 
  │ │      [ ]   Support digital beep via input layer (NEW)                            │ │ 
  │ │      [ ]   Support jack plugging notification via input layer (NEW)              │ │ 
  │ │      [ ]   Support initialization patch loading for HD-audio (NEW)               │ │ 
  │ │      [*]   Build Realtek HD-audio codec support (NEW)                            │ │ 
  │ │      [*]     Build static quirks for Realtek codecs (NEW)                        │ │ 
  │ │      [*]   Build Analog Device HD-audio codec support (NEW)                      │ │ 
  │ │      [*]   Build IDT/Sigmatel HD-audio codec support (NEW)                       │ │ 
  │ │      [*]   Build VIA HD-audio codec support (NEW)                                │ │ 
  │ │      [*]   Build HDMI/DisplayPort HD-audio codec support (NEW)                   │ │ 
  │ │      [*]   Build Cirrus Logic codec support (NEW)                                │ │ 
  │ │      [*]   Build Conexant HD-audio codec support (NEW)                           │ │ 
  │ │      [*]   Build Creative CA0110-IBG codec support (NEW)                         │ │ 
  │ │      [*]   Build Creative CA0132 codec support (NEW)                             │ │ 
  │ │      [*]   Build C-Media HD-audio codec support (NEW)                            │ │ 
  │ │      [*]   Build Silicon Labs 3054 HD-modem codec support (NEW)                  │ │ 
  │ │      [*]   Enable generic HD-audio codec parser (NEW)   
And where is PnP - it is not supported by emerged alsa

localhost xi # emerge --info | wgetpaste
Your paste can be seen here: http://bpaste.net/show/54833/
localhost xi # lspci -v | grep -i audio | wgetpaste
Your paste can be seen here: http://bpaste.net/show/54835/
localhost xi # cat /usr/src/linux/.config | wgetpaste
Your paste can be seen here: http://bpaste.net/show/54836/
96
Linux Servers Support / Wordpress multisite rewrite rules
« Last post by vv22 on October 26, 2012, 06:56:51 AM »
1) I have a Wordpress multisite subdomain installation with about 100 sites in the network.

Network Admin - Sites (All Sites) shows them like this:

main site: "www.domain-name.com"
all other sites: "subdomain-name.domain-name.com"

there is also a domain mapping plugin, so they all get access as separate urls:

http://domain-name1.com/
http://domain-name2.com/
...
http://domain-name100.com/

2) Currently urls on all blogs are set to:

http://domain-name.com/2012/10/26/post-name
http://domain-name.com/category/category-name

(I used today's date as an example)

This is also the way domains show in Google and Bing search results

3) I am going to remove "2012/10/26/" and "category/" from the urls, so they are gonna look like this:

http://domain-name.com/post-name
http://domain-name.com/category-name

...and I need to have a rewrite rule that takes care of redirecting people coming from serps to these new urls

4) I have something like this right now:

Code: [Select]
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http://domain.com/$4 [L,R=301]

Code: [Select]
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^([0-9]{4})/([0-9]{2})/([0-9]{2})/(.*)$ http://domain.com/$4 [L,R=301]

but I am not sure if it is correct / if it is gonna work right, and also I need to have a rule for all 100 websites, and not just one. These versions (only one of them was meant to be used) dont include the "category/" part either.

5) If somebody would have an idea how to do that it would be great.

Thank you in advance for any info.
97
Linux Servers Support / Postfix - Send mails to specific domains only
« Last post by sunnysthakur on October 25, 2012, 04:02:46 PM »
Hello,

I am working on postfix server on CentOS 5.8 which will be send mails to a specific domain only.[i.e gmail.com]

All the things are nearly finished but i am not getting how to setup the postfix to send mails to specific domains.

Please help me out.

Thanks,
Sunny
98
Linux Development & Programming / Please Help
« Last post by bgriffeth on October 08, 2012, 06:48:26 AM »
I just start learning about linux. Here is a exercises of the lesson. Does anyone help me write down the command? I am having some problem.

1. Switch to root

2. Create new user called a6

3. Assign password to user created in step 2

4. Create new group called 1032

5. Create new file called permissions-test by using touch command

6. Display permissions of file you just created in step 5

7. Assign ownership of file permissions-test to user a6 and group 1032

8. Change the permissions of file permissions-test to match the following:

-Owner=Read,Write,Execute

-Group=Read,Execute

-Everyone Else=Execute

9. Display newly changed permissions of the file permissions-test

10. Display your default permissions level assigned by Linux

Please write a brief description of the purpose and the options of following network interface commands in Linux:

1. ifconfig

2. ping

3. nslookup

4. traceroute

5. netstat
99
Forum Talk / Please help
« Last post by bgriffeth on October 08, 2012, 06:22:09 AM »
So I'm trying to complete these steps and for some reason I can't get it to work. Could someone walk me through how to do it so I can see what I have either done wrong or maybe missed.

1. Create new user on your system with userid=operator and with your first and last name associated

2. Assign a password for the operator user

3. Create new group called administrators

4. Add operator user to the administrators group (make sure to use non-default group option)

5. Use yum to install finger command

6. Perform finger on operator user

7. Use cat in combination with grep command to list operator line only in /etc/passwd

8. Delete user operator from your system using an option to remove all it's files

9. List /home directory

Thank you
100
Linux Servers Support / Configure Samba with Remote LDAP for Authentications.
« Last post by sunnysthakur on October 01, 2012, 03:11:14 PM »
I am working on configuring Samba with Remote LDAP for Authentications but facing issue on the same.

I googled for the this but most of the setup is to connect local Samba and LDAP with samba-ldap tools [All are on the same machine] but in my case this is on a separate machines.

Please help me to configure this.

Thanks.
Pages: 1 ... 8 9 [10]