Kindly help me out to convert this script to shell script.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Kindly help me out to convert this script to shell script.
# 1  
Old 03-14-2013
Kindly help me out to convert this script to shell script.

Code:
 set +v
echo "Program Name               :" $0
#  echo "Next param                 :" $1
echo "Next param                 :" "Username/Password"
echo "User Id                    :" $2
echo "User Name                  :" $3
echo "Request ID                 :" $4
echo "Original File Name         :" $5 
echo "Interface File Name        :" $6 
echo "Path Name                  :" $7
echo "Destination Path           :" $8

D:
cd $7

echo "Process Output files"
#IF NOT EXIST $8 GOTO MAPERROR
IF $8 
THEN
goto MAPERROR
#IF EXIST $5 (COPY $5 $8\$6) ELSE echo "Output file does not exist"
#GOTO ENDPROCESS
if $5
then (cp $5 $8/$6)
else
echo "Output file does not exist"
:MAPERROR
echo $8"The Share Directory has not been mapped. Contact your System Administrator"
#EXIT -1
exit -1  
:ENDPROCESS
echo "Process finished. Goodbye"

---------- Post updated at 07:19 AM ---------- Previous update was at 07:15 AM ----------

i have tried this one,but its not working.kindly give ur inputs
Code:
 set +v
  echo "Program Name               :" $0
  #  echo "Next param                 :" $1
  echo "Next param                 :" "Username/Password"
  echo "User Id                    :" $2
  echo "User Name                  :" $3
  echo "Request ID                 :" $4
  echo "Original File Name         :" $5 
  echo "Interface File Name        :" $6 
  echo "Path Name                  :" $7
  echo "Destination Path           :" $8
  
  cd $7
  echo "Process Output files"
  if [ ! -d "$8" ]; then
   echo "The Share Directory has not been mapped. Contact your System Administrator"
   exit 1
  else
     if [ -d "$5" ]; then
     cp $5 $8/$6
  else
     echo "Output file does not exist"
     echo "Process finished. Goodbye"
     fi
  fi


Last edited by Franklin52; 03-14-2013 at 09:40 AM.. Reason: fixed code tags
# 2  
Old 03-14-2013
For starters, I would write all the echo statements as follows
Code:
  echo "Program Name               : $0"
  echo "Next param                 : Username/Password"
  echo "User Id                    : $2"
  echo "User Name                  : $3"
  echo "Request ID                 : $4"
  echo "Original File Name         : $5" 
  echo "Interface File Name        : $6" 
  echo "Path Name                  : $7"
  echo "Destination Path           : $8"

You also have a problem with your conditional (if) statements. Read any bash shell script guide and you should be able to figure out what is wrong.
# 3  
Old 03-14-2013
Some corrections (always quote: "$variable")
Code:
 set +v
  echo "Program Name               : $0"
  #  echo "Next param                 : $1"
  echo "Next param                 : Username/Password"
  echo "User Id                    : $2"
  echo "User Name                  : $3"
  echo "Request ID                 : $4"
  echo "Original File Name         : $5"
  echo "Interface File Name        : $6"
  echo "Path Name                  : $7"
  echo "Destination Path           : $8"
  
  cd "$7" || exit # fatal
  echo "Process Output files"
  if [ ! -d "$8" ]; then
    echo "The Share Directory has not been mapped. Contact your System Administrator"
    exit 1
  fi # because of the exit we dont need else here
  if [ -f "$5" ]; then
    cp "$5" "$8/$6"
  else
    echo "Output file does not exist"
    echo "Process finished. Goodbye"
  fi

# 4  
Old 03-15-2013
Thank You

Thank you so much for the kind reply..
But am still getting the message as Share directory cannot be mapped, please contact your system admin.
what change has to be done?
can anyone suggest..
# 5  
Old 03-17-2013
Could you please give the other relevant output
Original File Name : ?
Interface File Name : ?
Path Name : ?
Destination Path : ?

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert my shell script to C programming HELP!!

I had try to create a basic shell script. So now im trying to convert in to C-programming language can some one guide/help me out with it?(BTW IM USING A LINUX/UNIX/ORACLE SYSTEM) CODE BELOW !/bin/bash for i in `ls -1 /cslab/home/JAZEL/` do cp -uv $i /cslab/home/JAZEL/cs295/$i.`date... (2 Replies)
Discussion started by: Nygenesis
2 Replies

2. Shell Programming and Scripting

Convert shell script to Perl

Hello,,I have a very small script that contains these lines; and it works perfectly; however I need to use Perl now as I will need to feel variables from a MySQL table into this; to it would be nice to start by converting this first... find / -perm 777 \( -type f -o -type d \) -exec ls -lid {}... (1 Reply)
Discussion started by: gvolpini
1 Replies

3. Shell Programming and Scripting

convert to shell script

how to convert these code to shell script #include<stdio.h> #include<conio.h> main() { int i,j,a=0,b=0,c=0,f,t,al,ta; int a1, max, n, n1,p,k=0; printf(“\n enter no.of resources”); scanf(“%d”,n1); printf(“\nenter the max no .of resources for each type”); for(i=0;i<n1;i++)... (4 Replies)
Discussion started by: syah
4 Replies

4. Red Hat

May you convert vbscript to shell script?

Dear! I've a script (vbscript) running on windows machine for along time ago. 2 weeks ago, we changed server from Windows to RHEL5, and this script did not run, and I'm not programmer. So that, I post this script here and wish you convert for me. vbscript code: 'This script will: ' - ZIP... (1 Reply)
Discussion started by: trantuananh24hg
1 Replies

5. Shell Programming and Scripting

Help: how to convert perl script to shell script

bash$ mdb-schema x.mdb | perl -wpe 's%^DROP TABLE %DROP TABLE IF EXISTS %i; s%(Memo/Hyperlink|DateTime( \(Short\))?)%TEXT%i; s%(Boolean|Byte|Byte|Numeric|Replication ID|(\w+ )?Integer)%INTEGER%i; s%(BINARY|OLE|Unknown (+)?)%BLOB%i; s%\s*\(\d+\)\s*(,?*)$%${1}%;' | sqlite3 x.db ... (1 Reply)
Discussion started by: jackpapa
1 Replies

6. Shell Programming and Scripting

how to convert a shell script to a php script for displaying next word after pattern match

I have a shell script which I made with the help of this forum #!/bin/sh RuleNum=$1 cat bw_rules | sed 's/^.*-x //' | awk -v var=$RuleNum '$1==var {for(i=1;i<=NF;i++) {if($i=="-bwout") print $(i+3),$(i+1)}}' Basically I have a pages after pages of bandwidth rules and the script gives... (0 Replies)
Discussion started by: sb245
0 Replies

7. Shell Programming and Scripting

convert shell script into a binary executable

Hello every one, i want to convert my shell script into a binary executable a .exe file , is it possible to do that if so are there any tools . Would the script take off when the arguments are parsed. Thanks Venu (13 Replies)
Discussion started by: venu
13 Replies

8. Shell Programming and Scripting

convert PERL script to SHELL script

Hi all experts, I am new to Unix. Could you please help me to convert the following PERL script to SHELL? I will appreciate. #!/bin/sh use strict; use warnings; my $robot_num = 0; my %rob_tapes; foreach (`/usr/openv/volmgr/bin/vmquery -l -rn $robot_num`) { $rob_tapes{(split)} = 1; }... (6 Replies)
Discussion started by: ma466
6 Replies

9. Shell Programming and Scripting

please convert the below program into shell script

if ( ( grep -i "Exception : " /home/dklog* )) then echo " improper combination" elsif ( ( grep -i "invalid" /home/dklog*)) then echo " wrong process " fi fi in the above case i am facing the the syntx error please help in this case... (3 Replies)
Discussion started by: mail2sant
3 Replies

10. Shell Programming and Scripting

Convert shell script for looping

Situation: I have a working shell script on our file server (OSXS Tiger) to connect to a workstation, which is using a portable home directory (phd), and rsync a user's MirrorAgent.log. I'm not that strong of a scripter (obviously), but I would like to add other workstations to this script as they... (4 Replies)
Discussion started by: le0pard13
4 Replies
Login or Register to Ask a Question