Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Help, Linux Script


  • Please log in to reply
4 replies to this topic

#1 jrdncchr

jrdncchr

  • Members
  • 8 posts
  • OFFLINE
  •  
  • Local time:09:59 AM

Posted 08 March 2011 - 06:06 AM

#!/bin/bash
args=("$@")
echo "#================================="
echo "#Script Name:"
echo "#By:"
echo "#Purpose:"
echo "#:Command Line: picoc"
echo "#================================="
pico $@

this is my script. i think it is ok w/o error. but when i run it i got error. i'm using a VMBox w/ Ubuntu for my linux.
the error says:

sample: 7: Syntax error: "(" unexpected

i dont know how to fix it. maybe it is just here in my terminal. can i fix it? do i need to customized somethings in bash or somewhere? pls help. :)

Edited by jrdncchr, 08 March 2011 - 06:57 AM.


BC AdBot (Login to Remove)

 


#2 Romeo29

Romeo29

    Learning To Bleep


  • Members
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:09:59 AM

Posted 08 March 2011 - 06:37 AM

Why are you doing this ? You are passing command argument to pico, so why not invoke pico with same command argument?

Edited by Romeo29, 08 March 2011 - 08:14 AM.


#3 jrdncchr

jrdncchr
  • Topic Starter

  • Members
  • 8 posts
  • OFFLINE
  •  
  • Local time:09:59 AM

Posted 08 March 2011 - 06:54 AM

Why are you doing this ? You are passing command argument to pico, so why not invoke pico with same command argument?

To correct the script, just remove the brackets in args=("$@")
or use the {} brackets.


becuase my proposal is to have a command "picoc" that when it run, it will run same as "pico" but with comments written above..

can u help me? when i change () to {}, the comments are not in pico, but it echoed outside. :|

Edited by jrdncchr, 08 March 2011 - 06:56 AM.


#4 Romeo29

Romeo29

    Learning To Bleep


  • Members
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:09:59 AM

Posted 08 March 2011 - 08:05 AM

If you just want to echo comments and pass the arguments to pico, why are using the args variable?

#!/usr/bin/bash
echo comments1
echo comments2
pico "$@"
if you want use a variable to pass the arguments, then do it like this.

args="$@"
pico $args
If you want to store an array, then use the () brackets. But why would you do that for just passing the arguments

args=("$@")
pico ${args[0]} ${args[1]} ${args[2]}

Edited by Romeo29, 08 March 2011 - 08:17 AM.


#5 tomdick789

tomdick789

  • Members
  • 3 posts
  • OFFLINE
  •  
  • Local time:09:59 AM

Posted 08 April 2011 - 02:21 PM

k =`grep -i success /var/seamless/spool/tdr/ERS_200804$date1$i* | wc -l`
echo $k
done




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users