Why Wont My Code Work, " SyntaX Error: Unexpected End Of File"

i have been trying to get this peice of code to work but i cant seem to get it to work.
im just starting out coding and kinda poking around in the dark to get this resolved, any help would be much appriciated, thankyou


Quote:
#!/bin/bash

echo "Would you like to scan using nmap or hping?"

read scanner

if "$scanner" = "nmap" : then

echo "Enter the starting IP address :"

read FirstIP

echo "Enter the last IP address :"

read LastIP

echo "Enter the port number you want to scan for :"

read port

nmap -sT $FirstIP-$LastIP -p $port -oG web
cat web | grep open > web1
cat web1 | cut -f2 -d ":" | cut -f1 -d "(" > web2
cat web2


elit



echo "Which IP address would you like to scan?"

read IPaddress

echo echo "What port would you like to scan for ?"

read hpingport

echo "How many packets would you like to send?"

read packets

hping3 -c $packets $IPaddress -p $hpingport > hpingscan

cat hpingscan
thankyou for any help


Similar Content



Help With 'CASE'

Hi guys,

i'm beginner with Unix, I tried my best, but I Really don't know how to finish it .

here's my problem : I have to do something like Student system - student's name | subjects | mark |credits.

after starting script it will ask you for Student's name, then which subject, then the mark will appear.

It's a homework, and I have my own idea how to solve it, but cannot finish it, i don't want complete solution, just a help!

Code:
#!/bin/bash
echo "Students name"
echo -n "Enter student's name: "
read name
echo
case $name in
Example1|Math) echo "C" ;;
Example2|Programming) echo "D" ;;
Example3|WWW) echo "A" ;;
Example4|Economie) echo "-" ;;
esac

I don't now how to bring together case with second things which is "enter subject".

I appreciate any help

Check Empty Variable Without Comments

Hello,

They gave me this:
Code:
#!/bin/bash

# Write error message on stderr and die
function die() {
  echo "$@" >&2
  exit 1
}

# Load var from properties files
function load() {
  for propertie in "$@" ; do
    [[ -f "${propertie}" ]] || die "load() : \"${propertie}\" don't exist !"
    while read ; do
echo "${REPLY%=*}"
echo "${REPLY#*=}"
      [[ -n "${REPLY%%=*}" && -z "${REPLY#*=}" ]] || die "load() : Variable \"${REPLY%%=*}\" is empty!"
      eval "${REPLY%%=*}"=\'"${REPLY#*=}"\'
    done < "${propertie}"
  done
}

load "manage_srcds.conf"
echo "SRCDS_TICKRATE=$SRCDS_TICKRATE"
echo "SRCDS_SCREEN=$SRCDS_SCREEN"
echo "SRCDS_SRCDS_GAME_NAME=$SRCDS_GAME_NAME"
echo "SRCDS_MAXPLAYERS=$SRCDS_MAXPLAYERS"

but, return:
Quote:
###################################################
###################################################
load() : Variable "###################################################" is empty!

cat manage_srcds.conf

I just wish that there was no empty variable excluding those who do not have integer.

Best regards,

Help With Applying Passing Parameters

i need to complete this exercise but my code has some issues
HERE is the PRoblem:
Create a script that can accept ANY amount of numbers from the command line. Process the numbers one at a time, where numbers greater than 10 print “large”, numbers less than or equal to 10 print “small”
E.g. process 5 10 15 would print
small
small
large

and here is my code so far
if [ $@ -le "10" ]
then
echo "smaller"
else
echo "bigger"
shift
fi
if [ $@ -le "10" ]
then
echo "smaller"
else
echo "bigger"
shift
fi
if [ $@ -le "10" ]
then
echo "smaller"
else
echo "bigger"
shift
fi
if [ $@ -le "10" ]
then
echo "smaller"
else
echo "bigger"
shift
fi

any help would be greatly appreciated

Rsync Script Problem

Hi all,

I am trying to write a script that syncs files from source to destination. I have one centralized server that can ssh to any servers without pw. Now when I run the script, it can ssh to source server perfectly fine, but you need to enter password for destination server. Was wondering how I can clean this up before I start using case statements

Below is a sample I wrote

#!/bin/bash

#This scripts syncs shit

echo "Type in ID: "
read ID

echo "Type in Server : " #source server
read S

echo "Type in Destination Server: "
read DS

if [ $S == 9 ]; then
ssh -t "root@"$S"webserver1" "rsync -av /home/rlui/"$ID "root@"$DS"webserver2:/home/rlui/";
ssh -t "root@"$S"webserver1" "rsync -av /home/rlui/tmp/"$ID "root@sl"$DS"webserver2:/home/rlui/tmp/"
exit 1

where S and DS are cluster numbers

I apologize in advance if I am not clear on anything

How Can I Grep Variable?

I want to And search grep shell

but It's hard to grep variable


---------------------------------------------------------------
#!/bin/bash


if [ $# -eq 0 ]
then
echo "Ussage: phone searchfor [...searchfor]"
echo "(You didn't tell me what you want to search for )"

else

pass=0
find=""

for idx in $*
do
if [ -n "$idx" ]
then
if [ $pass -eq 0 ]
then
find=$(egrep "$idx" mydata)
pass=1

else

find=$("$find" | grep "$idx")

echo $find
fi
fi

done

if [ -z "$find" ]
then
echo "There is no such thing"
else

echo $find | awk -f display.awk

fi

fi

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

there is one error : command not found

in find=$("$find" | grep "$idx")

how can I grep variable and store it into variable?

Parameter $1 Isn't Returned After A Case (bash Scripting)

Hello everyone,

I recently started using "function" and "case" in linux but I came across a slight problem

My code:

Code:
function Return
{
echo $1
}

case "$1" in 
 ""       ) echo "give parameters please";;
 [0-9]*   ) echo "No numbers please";;
 *        ) Return;;



So whenever the first parameter is a simple word I would like it returned, but it seems like there is no returned string (empty space)

Also I know I can just write "echo $1" instead of Return, but I'd like to use a function for this.

Can anyone tell me why the function doesn't return $1? Thanks!

String Concatenation In UNIX / Shell Script

Hi,

I am new to UNIX - i wrote this below script based on the requirement. But i am stuck at the concatenation (at the second last step of the code)

The below code is working fine till the concatenation(second last step) - I need to concatenate Hello to the "physId" e.g. - The filename is UM123456789.20150503 - i am extracting M123456789 and i need to append "HELO" to it at the end. But as per the below script - when i am using the concatenation, it is overwriting the M123456789 and the output thus becomes HELO456789. I am trying to get the output as - M123456789HELO - where am i going wrong?

on the terminal i checked - echo $0 and it gave -> /bin/sh. Hence i wrote the below code.

#!bin/sh
absolutePath=/abc/data/abc_unix/stg/decrypt/*.*
filepath=$(echo ${absolutePath%.*})
echo "$filepath"
filenameext=$(echo ${filepath#/abc*decrypt/})
echo "$filenameext"
file=$(echo ${filenameext#.*})
echo "$file"
extract_physId=$(echo ${file:1:9})
physId=$(echo ${extract_physId})
echo "$physId"
key="$physId"HELO
echo "$key"

Better Way Of Writing This Command Of Leaving Multiple Blank Lines

Hi All..

I need to give four lines of gap(Freespace) between two command outputs.

what i did was below

Code:
echo "" >>$LOG_DIR/$LOG_NAME
echo "" >>$LOG_DIR/$LOG_NAME
echo "" >>$LOG_DIR/$LOG_NAME
echo "" >>$LOG_DIR/$LOG_NAME
print "***************** LEVEL 2: Truncating  Tables: Success:  tables Truncated ***********************" >> $LOG/$LOG_NAME
echo "" >>$LOG_DIR/$LOG_NAME
echo "" >>$LOG_DIR/$LOG_NAME
echo "" >>$LOG_DIR/$LOG_NAME
echo "" >>$LOG_DIR/$LOG_NAME
# Run the load scripts.
echo "***************** LEVEL 3: Loading Dupe Check Tables: Success: Dupe Check tables Loaded***********************" >> $LOG/$LOG_NAME


Is there any better way of writing this command to leave multiple lines between two commands.

Please advise...

Would Like To "echo" A Line, "read" Reply, Then Execute The Reply: How In Bash?

Apologies. I've been out of Unix for 14 years, and the gears have rusted. Also, Unix has changed - enough similarities to memory that I'm pretty comfy though.

Glad to see lots of info available via google. However changes are going to take getting used to. Have set up a testbed of 3 nearly identical machines, hoping to make an (at home) private network where I can automate installs and set-ups using NIS and NFS (Similar to work I once did).

Have found useful scripts interspersed with comments, would like to copy and paste them to a bash script that:

Reads the line.
Echos the line.
Reads the reply.
Executes what is typed.

Essentially, by making myself type (or copy & paste) the commands I think I'll become familiar.

Figured I'd use a spreadsheet, select the file, and paste into column B of the spreadsheet. In column A I'd paste:

echo "

and in column C I'd paste:

"

Then I'd cut and paste into a text document, insert the lines:

read A
$A

behind every command necessary to the actual task.

Figured I'd have to escape the ' and ".

Ran a test (test.bash):

#!/bin/bash
for i in `seq 1 10`;
do
echo "Enter a command:"
read A
echo "Trying $A"
$A
done

works fine when I type

ls -alg

but not so when I type

ls -alg | grep dwrx

so I'm wondering if someone has a suggestion?

Thanks for any ideas.

What Is A Good Linux Script For Changing An IP Address Statically In Ubuntu?

I have a shell script that currently changes the mac address of eth0 repeatedly. However, it does not change the public IP address, confirmed by wget -qO- ipinfo.io/ip .

PERIOD=10

while [ 1 ]
do
echo "Changing mac address..."
let lastup=`date +%s`
macchanger -A eth0
let diff=`date +%s`-$lastup
if [ "$diff" -lt "$PERIOD" ]
then
sleep $(($PERIOD-$diff))
echo "Changed mac address successfully."
echo
elif [ "$diff" -gt "$PERIOD" ]
then
echo "Command took longer than iteration period of $PERIOD seconds!"
fi
done

The script needs to change the IP Address statically.

Also, ultimately, what I am trying to accomplish, for security reasons, is to frequently and automatically change a computer's public IP address and mac address. This way, my office's computers, when using the Internet, has an additional form of protection.