Problems executing script

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Problems executing script
# 1  
Old 05-06-2012
Question Problems executing script

Hi, I'm a complete novice to Linux and UNIX. I'm having trouble getting a script to execute properly. I did a similar script earlier in the semester with no problems. For whatever reason I can't get this one to work. Any help would be greatly appreciated as I'm completely lost and frustrated at this point!I apologize in advance if I don't use proper terms, I'm not familiar with all the technical jargon yet!

I created a script using vi, named filepro
This is the format we need to use:
Code:
#!/bin/ksh 
cat <<++ 
 
MAIN MENU 
1) Print current working directory 
2) Delete file in current directory 
3) Rename file in current directory 
++ 
 
echo Please enter your selection $LOGNAME:

I made it executable with:
Code:
Chmod 755 filepro
./filepro

Everything appears to be to be correct
When I type in filepro I get:

Code:
MAIN MENU 
1) Print current working directory 
2) Delete file in current directory 
3) Rename file in current directory 
Please enter your selection LNOWE:

No matter what I select 1-3
I get an error message:
Code:
1: not found 2: not found etc...

I’ve tried adding and removing spaces in the main menu. I tried #!bin/bash, #!bin/sh. Adding and removing space between cat <<.
This is obviously a simple straight forward script. But I can’t seem to get it right. Please help. Thanks!Smilie

Lewis and Clark Community College, Godfrey, IL, US
Prof Rick Burgess, CNET 200 Intro to UNIX and Linux.

Moderator's Comments:
Mod Comment Not in required homework format. Thread closed

Last edited by Scrutinizer; 07-08-2012 at 07:43 AM.. Reason: Added code tags, removed formatting
# 2  
Old 05-06-2012
Hi, where is the part where you read the answer and what do you need to do with the answer? Could you please format you post so that it adheres to the standard formatting for homework posts?
# 3  
Old 05-07-2012
1. Please enter your selection LNOWE:

In your code, put $LOGNAME in SINGLE QUOTES ''
'$LOGNAME' or try prefixing a \to $ \$LOGNAME
your current script is interpolating the value of $LOGNAME defined as an environment variable

2. No matter what I select 1-3
I get an error message

What are you doing with the input recieved from user? you are not reading it hence getting error.

Also, as far as I know there should be no unwanted spaces in a here document so try removing any unwanted white spaces betwee the ++ block

Last edited by vbe; 05-08-2012 at 05:05 AM..
# 4  
Old 05-07-2012
Your code never asks for input. Your program FINISHES by the time you're typing anything in. You need to use the read command to read input after you show the menu. read VARNAME
# 5  
Old 05-07-2012
Quote:
Originally Posted by Corona688
Your code never asks for input. Your program FINISHES by the time you're typing anything in. You need to use the read command to read input after you show the menu. read VARNAME
Thanks, as soon as I read that I realized what I did. Still trying to figure all of this out.
Thanks again
# 6  
Old 07-08-2012
Reply to uir query

Hi ,

I think the problem is that ,you haven't specified where should the menu get the data from i;e inputs ,you should provide all the details like where the input comes from and where u want to display data....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Problems executing an interactive shell script

I am new to Unix shell and to this forum. I am having some trouble executing an interactive shell script that I have written using Mac TextEdit that takes a user input via terminal of a file type (jpg or gif) and then activates a script that will iterate through a folder of unsorted file types... (4 Replies)
Discussion started by: Braveheart
4 Replies

2. Shell Programming and Scripting

Executing Oracle script from UNIX Script

Hi, I am new to UNIX and want to execute oracle script from unix script. I have written below script but i am getting below error. #!/bin/bash file="/home/usr/control/control_file1" while read line do #$line=@$line #echo $line sqlplus tiger/scott@DB @$line exit #echo "$line" done... (3 Replies)
Discussion started by: vipin kumar rai
3 Replies

3. Shell Programming and Scripting

Remotely Executing Shell Script - Problems

Hey Lads, I have a shell script on a remote Server X that i need to execute from Server A. the script executes fine locally but remotely does not. It appears the script on the remote machine is calling another shell script which only has an array defined . Please see below the errors. ... (10 Replies)
Discussion started by: Irishboy24
10 Replies

4. UNIX for Dummies Questions & Answers

Script dosent exits after executing the script

Hi i wrote a script which dosent exists after executing any help #!/bin/bash netstat -ptlen | grep 10000 if ; then echo "Hive Thrift server is running" exit 0 else echo "Hive Thrift server is down Trying to Bring up the service" | mail -s "ALERT" team@domain.com `nohup hive... (7 Replies)
Discussion started by: vikatakavi
7 Replies

5. UNIX for Dummies Questions & Answers

Script not executing

Hello, I wasn't sure where to post this so I posted it here. I've used UNIX quite a bit, LINUX not so much. For some reason, my LINUX script will not execute if I type in the script name and press enter. I'm in the directory where the script is. test.sh However, when I use ". ./" it... (5 Replies)
Discussion started by: jsanders
5 Replies

6. Shell Programming and Scripting

Problems with remotely executing scripts

Hi, in the below command, i export a value to a variable which later is used by the script, however i dont see the exported value is actually been exported. ssh user@host "export var=/path/ ; cd /path/ ; ./script" how can i use the above command with proper value of var remotley (7 Replies)
Discussion started by: suraj.sheikh
7 Replies

7. Shell Programming and Scripting

Variables of executed script available in executing script

Hi, I have a script get_DB_var.ksh which do a data base call and get some variables as below: sqlplus -silent $user/$pass@dbname <<END select col1, col2, col3 from table_name where col4=$1; exit; END Now I want to access all these variables i.e.... (9 Replies)
Discussion started by: dips_ag
9 Replies

8. Debian

Problems with Crontab not executing scripts after edit

Hi all I installed Debian and i have a few scripts that outputs what is happening. The wierd part...after fresh install all works ok but after i open or edit Crontab it stops executing the scripts...and scripts runs manually so its not a problem with scripts...what happens is that i usually... (3 Replies)
Discussion started by: ro0t3d
3 Replies

9. UNIX for Advanced & Expert Users

Executing a shell script from windows;script present in unix

I need to execute a shell script kept in unix machine from windows. User id, password area available. For eg. There's a shell script wich moves all the logs kept in my home directory to a directory named LOGS. Now i need to get this done through windows; either using a batch file, or java... (4 Replies)
Discussion started by: rajneesh_kapoor
4 Replies

10. Shell Programming and Scripting

Problems executing SQL Plus sessions

If I execute this script: $ORACLE_HOME/bin/sqlplus -s <<EOF > oracle.log $DB_id/$DB_pswd@$DB_server start test.sql EOF the sql script executes with no errors. IF I execute the following script:... (12 Replies)
Discussion started by: mh53j_fe
12 Replies
Login or Register to Ask a Question