Linux.com

jabirali

jabirali

  • Linux.com Member
  • Posts: 157
  • Member Since: 30 Apr 10
  • Last Logged In: 10 Aug 11

Latest Posts

Posted by
Topic
Post Preview
Posted
  • jabirali
    RE: Mounting USB wireless adapter and hard drive
    It seems like only [i]ntfs-3g[/i] understands the mount option [i]silent[/i], which made the system assume that none of your harddrives were formatted with [i]vfat[/i]... Replace your fstab entries with these: [code]/dev/sda1 /mnt/usb vfat,ntfs-3g users,rw,noauto,umask=000,relatime 0 0 /dev/sdb1 /mnt/usb2 vfat,ntfs-3g users,rw,noauto,umask=000,relatime 0 0[/code] After running both [i]mount /mnt/usb[/i] and [i]mount /mnt/usb2[/i] as root, do you also get permission errors when you try to manually open the folders [i]/mnt/usb[/i] and [i]/mnt/usb2[/i] in your file manager? Also, we only got the first few lines of [i]/etc/group[/i]... Can you post the rest? You can get the entire contents at once like this:[code]cat /etc/group[/code]
    Link to this post 29 May 10

    It seems like only ntfs-3g understands the mount option silent, which made the system assume that none of your harddrives were formatted with vfat... Replace your fstab entries with these:

    /dev/sda1 /mnt/usb vfat,ntfs-3g users,rw,noauto,umask=000,relatime 0 0
    /dev/sdb1 /mnt/usb2 vfat,ntfs-3g users,rw,noauto,umask=000,relatime 0 0

    After running both mount /mnt/usb and mount /mnt/usb2 as root, do you also get permission errors when you try to manually open the folders /mnt/usb and /mnt/usb2 in your file manager?

    Also, we only got the first few lines of /etc/group... Can you post the rest? You can get the entire contents at once like this:

    cat /etc/group

  • jabirali
    RE: [Resolved] ARG..... HELP PLEASE c:bob.txt filename
    [b]marc wrote:[/b] [quote]Doesn't "pwd" actually look for the $PWD variable? ;)[/quote]I believe you're right... I just wanted to show how to use the output of a command too, since he first tried using something like "pwd/filename" and not "PWD/filename" :-)
    Link to this post 29 May 10

    marc wrote:

    Doesn't "pwd" actually look for the $PWD variable? ;)
    I believe you're right... I just wanted to show how to use the output of a command too, since he first tried using something like "pwd/filename" and not "PWD/filename" :-)

  • jabirali
    RE: Mounting USB wireless adapter and hard drive
    Replace the previous entry in [i]/etc/fstab[/i] with this: [code]/dev/sda1 /mnt/usb vfat,ntfs-3g users,rw,noauto,umask=000,relatime,silent 0 0[/code] That should create a more general entry that works with both your external harddrives. If you intend to work with both harddrives at the same time, you can create another mountpoint and [i]/etc/fstab[/i]-entry:[code]su -c "mkdir /mnt/usb2"[/code][code]/dev/sdb1 /mnt/usb2 vfat,ntfs-3g users,rw,noauto,umask=000,relatime,silent 0 0[/code] The reason it didn't work out of the box this time, must either be due to permissions issues, or due to problems with HAL. We might be able to fix the automounting; could you post the contents of the file [i]/etc/group[/i] so we can check if these are more permissions-issues?
    Link to this post 29 May 10

    Replace the previous entry in /etc/fstab with this:

    /dev/sda1 /mnt/usb vfat,ntfs-3g users,rw,noauto,umask=000,relatime,silent 0 0

    That should create a more general entry that works with both your external harddrives. If you intend to work with both harddrives at the same time, you can create another mountpoint and /etc/fstab-entry:
    su -c "mkdir /mnt/usb2"
    /dev/sdb1 /mnt/usb2 vfat,ntfs-3g users,rw,noauto,umask=000,relatime,silent 0 0

    The reason it didn't work out of the box this time, must either be due to permissions issues, or due to problems with HAL. We might be able to fix the automounting; could you post the contents of the file /etc/group so we can check if these are more permissions-issues?

  • jabirali
    RE: [Resolved] ARG..... HELP PLEASE c:bob.txt filename
    I'm glad it worked! [b]Digiza wrote:[/b] [quote]kept trying "pwd/c:osaso_security_rules.txt" and was giving strange errors :P[/quote]Aha... If you want the output of the environment variable [i]PWD[/i], you use [i]$PWD[/i]. If you wanted the output of the command [i]pwd[/i], you could have used $(pwd) instead. They both would have done the same :)
    Link to this post 29 May 10

    I'm glad it worked!

    Digiza wrote:

    kept trying "pwd/c:osaso_security_rules.txt" and was giving strange errors :P
    Aha... If you want the output of the environment variable PWD, you use $PWD. If you wanted the output of the command pwd, you could have used $(pwd) instead. They both would have done the same :)

  • jabirali
    RE: Driver for Built-in webcam
    [b]marc wrote:[/b] [quote]Would you mind explaing what that sentence does? I mean, step by step ;)[/quote]Sure, I'll explain everything :) To take it from the beginning, you might be familiar with the basic logic operators '&&' and '||'. The following is used to run [i]command_1[/i], and then [i]command_2[/i] - if and only if [i]command_1[/i] is successful. [code]command_1 && command_2[/code] This is used to run command_2 only if command_1 is [b]not[/b] successful: [code]command_1 || command_2[/code] In the original script, I wrote something like this: [code]( command_1 && command_2 && command_3 ) || ( command_4; command_5)[/code] The parentheses are used to glue together several commands into one block of code. If one of the commands inside the first parentheses fails (that is, [i]command_1[/i], [i]command_2[/i] or [i]command_3[/i]), it counts as if the whole block of commands fails - and then the '||' operator makes sure the second block of code is executed instead ([i]command_4[/i] and [i]command_5[/i]). But when a block of commands consists of seven different commands, the script gets easier to manage if the commands are spread through different lines. You can do this by escaping the newlines ("\\" ), so that Bash will ignore them:[code]( command_1 \\ && command_2 \\ && command_3 ) \\ || ( command_4; command_5)[/code] But the forums added whitespace to the end of each line, here represented by red underscores: [quote]( command_1 \\[color=#FF0000]_[/color] && command_2 \\[color=#FF0000]_[/color] && command_3 ) \\[color=#FF0000]_[/color] || ( command_4; command_5)[/quote] This means that Bash reads "\\" instead of "\\", which makes the interpreter ignore the whitespace instead of ignoring the newline. (I discovered this by using [i]gvimdiff[/i] to compare the old, working script I had on my harddrive with with a copy of the script I copy/pasted from the forums.) I then used [i]sed[/i], a tool used for search-and-replace actions, to correct this. Using [i]sed[/i] is quite simple: [code]sed 's/old/new/g' filename[/code]The "s" stands for "substitute", the slash is a delimiter, and the "g" at the end means "global". Sed will then read the file [i]filename[/i] and substitute every occurrence of "old" in [i]filename[/i] with "new", and write the modified file to standard output. In this case, I wanted to replace every occurence of '\\ ' with just '\\'. Since Sed itself interprets backslashes (so that you e.g. can replace all newlines by using '\\n', or all tabs with '\\t' ), the backslashes themselves have to be escaped. If we also escape the whitespace, the pattern '\\ ' becomes '\\\\\\ ', and '\\' becomes '\\\\'. We also want to save the output back to the original file by piping the output: [code]sed 's/\\\\\\ /\\\\/g' filename > filename[/code] A more specific solution, and in many cases a better one, would be to replace '\\' with '\\': [code]sed 's/\\\\\\ \\n/\\\\\\n/g' filename > filename[/code] If not given any input files, [i]sed[/i] will read standard input, so something like this should work equally well: [code]cat filename|sed 's/old/new/g' > filename[/code] The 'g' at the end can also be replaced with a number: [code]sed 's/old/new/1' # Replace only 1. occurrence of "old" sed 's/old/new/2' # Replace only 2. occurrence of "old"[/code] Hope this helps :)
    Link to this post 29 May 10

    marc wrote:

    Would you mind explaing what that sentence does? I mean, step by step ;)
    Sure, I'll explain everything :)

    To take it from the beginning, you might be familiar with the basic logic operators '&&' and '||'. The following is used to run command_1, and then command_2 - if and only if command_1 is successful.

    command_1 && command_2

    This is used to run command_2 only if command_1 is not successful:
    command_1 || command_2

    In the original script, I wrote something like this:
    ( command_1 && command_2 && command_3 ) || ( command_4; command_5)

    The parentheses are used to glue together several commands into one block of code. If one of the commands inside the first parentheses fails (that is, command_1, command_2 or command_3), it counts as if the whole block of commands fails - and then the '||' operator makes sure the second block of code is executed instead (command_4 and command_5).

    But when a block of commands consists of seven different commands, the script gets easier to manage if the commands are spread through different lines. You can do this by escaping the newlines ("\\<newline>" ), so that Bash will ignore them:

    ( command_1 \\
    && command_2 \\
    && command_3 ) \\
    || ( command_4; command_5)

    But the forums added whitespace to the end of each line, here represented by red underscores:
    ( command_1 \\[color=#FF0000]_[/color]
    && command_2 \\[color=#FF0000]_[/color]
    && command_3 ) \\[color=#FF0000]_[/color]
    || ( command_4; command_5)

    This means that Bash reads "\\<space><newline>" instead of "\\<newline>", which makes the interpreter ignore the whitespace instead of ignoring the newline. (I discovered this by using gvimdiff to compare the old, working script I had on my harddrive with with a copy of the script I copy/pasted from the forums.)

    I then used sed, a tool used for search-and-replace actions, to correct this. Using sed is quite simple:

    sed 's/old/new/g' filename
    The "s" stands for "substitute", the slash is a delimiter, and the "g" at the end means "global". Sed will then read the file filename and substitute every occurrence of "old" in filename with "new", and write the modified file to standard output.

    In this case, I wanted to replace every occurence of '\\ ' with just '\\'. Since Sed itself interprets backslashes (so that you e.g. can replace all newlines by using '\\n', or all tabs with '\\t' ), the backslashes themselves have to be escaped. If we also escape the whitespace, the pattern '\\ ' becomes '\\\\\\ ', and '\\' becomes '\\\\'. We also want to save the output back to the original file by piping the output:

    sed 's/\\\\\\ /\\\\/g' filename > filename

    A more specific solution, and in many cases a better one, would be to replace '\\<space><newline>' with '\\<newline>':
    sed 's/\\\\\\ \\n/\\\\\\n/g' filename > filename

    If not given any input files, sed will read standard input, so something like this should work equally well:
    cat filename|sed 's/old/new/g' > filename

    The 'g' at the end can also be replaced with a number:
    sed 's/old/new/1' # Replace only 1. occurrence of "old"
    sed 's/old/new/2' # Replace only 2. occurrence of "old"

    Hope this helps :)

  • jabirali
    RE: [Resolved] ARG..... HELP PLEASE c:bob.txt filename
    Does this help? [code]scp "$PWD/c:osaso_security_rules.txt" gareth.thompson@prodtrans:/home/gareth.thompson/[/code]
    Link to this post 28 May 10

    Does this help?

    scp "$PWD/c:osaso_security_rules.txt" gareth.thompson@prodtrans:/home/gareth.thompson/

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board