(Linux) sudo + password bash script?

Hi, trying to make a script to mount partitions, need to sudo to be able to write to the root directory (the directory I want to make is /media/PartitionNameHere). New to Linux/scripting/CLI, don't know the proper syntax to add the password for sudo into the script (I understand it's a security issue,... show more Hi, trying to make a script to mount partitions, need to sudo to be able to write to the root directory (the directory I want to make is /media/PartitionNameHere).

New to Linux/scripting/CLI, don't know the proper syntax to add the password for sudo into the script (I understand it's a security issue, but this is my personal computer and that doesn't matter - I just want to learn the proper syntax with this question).

I've spent 3 full days googling to no avail.
I found 3 different methods I thought would work:
1.sudo usernamehere/passwordhere

2. su -
passwordhere

3. sudo -S
echo passwordhere | sudo -S

None work. The first two I kind of gleaned my searches to do, but the last one was somebody asking to do this exact thing.. BUT IT DIDN'T WORK EITHER (http://www.unix.com/shell-programming-scripting/108046-sudo-use-script-without-prompt-password.html)?

---------------------------------

ex.:
#!/bin/bash
sudo -S
echo passwordhere | sudo -S
sudo mkdir [...]
[rest of script]

I tried putting the echo line above sudo -S. I tried using quotes around the password (even though I think that's incorrect). Nothing. I'm dying here.

I don't want to add my username to sudoers or automount the drives with fstab, or whatever else. I want to learn the proper syntax for this >bash< script (no "expect," please).

Linux Mint Xfce 13.
Update: I do thank you guys for your help. I have gathered: "sudo is su without requiring root's password, but the sudoers file needs to be setup right for sudo to even work". However, my experience says otherwise: In a terminal, I sudo mkdir /test, type in the root/my password when prompted, and bam the dir... show more I do thank you guys for your help.

I have gathered: "sudo is su without requiring root's password, but the sudoers file needs to be setup right for sudo to even work". However, my experience says otherwise: In a terminal, I sudo mkdir /test, type in the root/my password when prompted, and bam the dir is made. AKA, No editing of the sudoers file necessary.

The 'echo $password etc' command also WOULD NOT WORK for me. Unless maybe that thing only works if I edit sudoers first... which may be the case. Retarded, if so; I certainly see the use on systems that need different privilege levels, but for single-users that's retarded (if you're a single user and editng sudoers, just make it require no password). Not what I want/ed, so I'm not bothering.

Giving up for the tim being.

(I wanted to create a dir in /media/whatever because when I manually mount my second internal hd, it mounts there, and I created a long vlc playlist that points to files in there -
Update 2: I do thank you guys for your help. I have gathered: "sudo is su without requiring root's password, but the sudoers file needs to be setup right for sudo to even work". However, my experience says otherwise: In a terminal, I sudo mkdir /test, type in the root/my password when prompted, and bam the dir... show more I do thank you guys for your help.

I have gathered: "sudo is su without requiring root's password, but the sudoers file needs to be setup right for sudo to even work". However, my experience says otherwise: In a terminal, I sudo mkdir /test, type in the root/my password when prompted, and bam the dir is made. AKA, No editing of the sudoers file necessary.

The 'echo $password etc' command also WOULD NOT WORK for me. Unless maybe that thing only works if I edit sudoers first... which may be the case. Retarded, if so; I certainly see the use on systems that need different privilege levels, but for single-users that's retarded (if you're a single user and editng sudoers, just make it require no password). Not what I want/ed, so I'm not bothering.

Giving up for the tim being.

(I wanted to create a dir in /media/whatever because when I manually mount my second internal hd, it mounts there, and I created a long vlc playlist that points to files in there -
2 answers 2