[Solved] [Bash] How can this NOT work?!?!

###### Samsung NC10 Commandcenter ######
#!/bin/bash
command=""
act=""
args=0
param=$2
if [ $# -eq 2 ]; then
    args=2
fi
add () {
if [ args!=2 ]; then
    echo "What do you want to activate?"
    echo -e "1) LAN\t2) WLAN\t3) Bluetooth"
    read act
fi
if [ args=2 ]; then
    act=$param
fi
    case $act in
        1)
        echo "Activating LAN."
        modprobe sky2;
        /etc/rc.d/network start;
        2)
        echo "Activating WLAN."
        modprobe ath5k;
        /etc/rc.d/network start;
        3)
        echo "Activating Bluetooth."
        modprobe btusb;
        modprobe bluetooth;
        echo "Invalid action '$act'!"
    esac
remove () {
if [ args!=2 ]; then
    echo "What do you want to inactivate?"
    echo -e "1) LAN\t2) WLAN\t3) Bluetooth"
    read act
fi
if [ args=2 ]; then
    act=$param
fi
    case $act in
        1)
        rmmod sky2;
        /etc/rc.d/network stop;
        2)
        rmmod ath5k;
        /etc/rc.d/network stop;
        3)
        rmmod btusb;
        rmmod bluetooth;
        echo "Invalid action '$act'!"
    esac
cmd () {
if [ args!=2 ]; then
    echo "What action do you want to perform?"
    echo -e "1) Suspend(RAM)\t2) Hibernate(HDD)"
    read act
fi
if [ args=2 ]; then
    act=$param
fi
    case $act in
        1)
        echo "Suspending to RAM."
        pm-suspend;
        2)
        echo "Hibernating to HDD."
        pm-hibernate;
        echo "Invalid action '$act'!"
    esac
if [ $# -ne 0 ]; then
    case $1 in
        add)
        command=1
        rm)
        command=2
        cmd)
        command=3
        command=$1
    esac
fi
if [ $# -eq 0 ]; then
    echo -e "Entering interactive mode. \nWhat task would you like to perform? \n1) Activate\t2) Inactivate\t3) Command"
    read command
fi
case $command in
    1)
    add
    2)
    remove
    3)
    cmd
    echo "Invalid parameter '$command'!"
esac
I'm trying to make a script to control the various functions of my awesome netbook, but even though my design is ingenious , it doesn't work. I've tried everything and I just don't see why it can't work.
If you start it without arguments, it will ask interactively for the arguments and it works. It works if you pass the first argument, it asks you straight for the second one.
But it doesn't work if you give both arguments directly. I've tried pretty much everything and I'm about to start punching in walls.
It's my first real bash script though...
Last edited by initbox (2009-03-08 16:00:20)

Now it works!
All I had to do was add $ in the if-variables and add spaces into the if-conditions.
Thanks guys.
Use it if you find it useful, don't care about credits or w/e.
Finished script:
#!/bin/bash
###### Samsung NC10 Commandcenter ######
command=""
act=""
args=0
param=$2
if [ $# -eq 2 ]; then
    args=2
fi
add () {
if [ $args -ne 2 ]; then
    echo "What do you want to activate?"
    echo -e "1) LAN\t2) WLAN\t3) Bluetooth"
    read act
fi
if [ $args = 2 ]; then
    act=$param
fi
    case $act in
        1|lan)
        echo "Activating LAN."
        modprobe sky2;
        /etc/rc.d/network start;
        2|wlan)
        echo "Activating WLAN."
        modprobe ath5k;
        /etc/rc.d/network start;
        3|bt)
        echo "Activating Bluetooth."
        modprobe btusb;
        modprobe bluetooth;
        echo "Invalid action '$act'!"
    esac
remove () {
if [ $args -ne 2 ]; then
    echo "What do you want to inactivate?"
    echo -e "1) LAN\t2) WLAN\t3) Bluetooth"
    read act
fi
if [ $args = 2 ]; then
    act=$param
fi
    case $act in
        1|lan)
        /etc/rc.d/network stop;
        rmmod sky2;
        2)
        /etc/rc.d/network stop;
        rmmod ath5k;
        3)
        rmmod btusb;
        rmmod bluetooth;
        echo "Invalid action '$act'!"
    esac
cmd () {
if [ $args -ne 2 ]; then
    echo "What action do you want to perform?"
    echo -e "1) Suspend(RAM)\t2) Hibernate(HDD)"
    read act
fi
if [ $args = 2 ]; then
    act=$param
fi
    case $act in
        1)
        echo "Suspending to RAM."
        pm-suspend;
        2)
        echo "Hibernating to HDD."
        pm-hibernate;
        echo "Invalid action '$act'!"
    esac
if [ $# -ne 0 ]; then
    case $1 in
        add)
        command=1
        rm)
        command=2
        cmd)
        command=3
        command=$1
    esac
fi
if [ $# -eq 0 ]; then
    echo -e "Entering interactive mode. \nWhat task would you like to perform? \n1) Activate\t2) Inactivate\t3) Command"
    read command
fi
case $command in
    1)
    add
    2)
    remove
    3)
    cmd
    echo "Invalid parameter '$command'!"
esac
Last edited by initbox (2009-03-14 12:12:26)

Similar Messages

  • Buddy list all gray--how can this not work??

    I've got iChat 3.1.8 and only opened it when i got a little Logitec USB camera. Plugged everything in, set all the settings, and added my buddy (another Mac user). I could not initiate a video chat because my buddy list names and icons are all gray. There are NO green icons at all. But she said I showed up just fine in her buddy list, and when she initiated the chat it worked perfectly. We had a nice chat. But when we tried again from my end, still no color in my life.
    The camera has worked fine since I plugged it in. I bought and installed iChatUSBCam v2.2.1, which allowed me to set a few more settings. Alas, nothing has changed.
    I've read this question a few times on the board and--most frustrating--they all seem to say "Oh, it worked itself out." But mine isn't working itself out. Camera and microphone are enabled. No one is blocked. I'm lost.
    ibook G4   Mac OS X (10.4.10)  

    Hi M Smith 1,
    Welcome to the Apple Discussions
    In System Preferences > Sharing > Firewall tab is the Firewall On ?
    Have you set the iChat ports in a New options if it Is ?
    Did those ports include 5190 on UDP ?
    If Yes to these three question use the Advanced button.
    Does this have the "Block UDP Traffic" item ticked ?
    If so deselect it.
    The iChat ports also need to be open in your modem and any separate router.
    If Port Forwarding was used here it must point to the IP that your computer is getting or using. ( See System Preferences > Network > (Select connection method) > TCP/IP tab )
    On some modems and or routers the forwarding or use of TCP and UDP protocols on port 5190 seems to cause a conflict.
    iChat can have the login to AIM and text chatting moved to a different port.
    iCHat > Preferences > Accounts
    Select the AIM or @mac account on the left
    Select the Server Settings tab
    Whilst Logged out of AIM change the port to 443.
    If all these do not work go to Users/(your Account)/Library/Preferences and delete com.apple.ichat.AIM.plist and restart ichat
    10:55 AM Monday; July 23, 2007

  • HT5246 Everyone has Java installed - how can this tool work?

    Every Mac (and PC user for that matter) has Java installed.  Even if you did not have it, Apple's last two updates installed new versions.  How can this malware tool work?  And why is it limited to Lion? 
    Apple - this is not what your customers rightly expect and could be crippling to your reputation.
    Do this over and do it right.  Thankyou.

    Every Mac (and PC user for that matter) has Java installed.
    That's incorrect.
    How can this malware tool work?
    By updating Java, if present, and removing the malware files, if present.
    And why is it limited to Lion?
    It isn't. There's a Java update for Mac OS X 10.6.8 that does the same things.

  • How can this pattern work? need help!!

    the model i need have 3layers:JSP+EJB+SocketServer, i know EJB can act as Socket Client(not Server),but the
    main problem is that i must use a .dll or .lib file(written in
    c) in EJB to packge the socket data.someone says EJB
    can use JNI while EJB Spec won't allow it, i dont't want
    to take the risk also.Is there any other way can work?
    (use runtime in EJB?)
    if EJB can't work in this pattern,can i have another choice? (JSP and SocketServer can't be replaced)
    NEED HELP!

    Use the Mediator pattern.

  • I keep getting the message: "what should firefox do with this file" in Windows XP every time I want to download a file, e.g., adobe, excel, etc. How can this annoying message be deleted? The check box to "open file automatically" does not work!

    I keep getting the message: "what should Firefox do with this file" in Windows XP every time I want to download a file, e.g., adobe, excel, etc. How can this annoying message be deleted? The check box to "open file automatically" does not work!

    cor-el,
    Thanks for your prompt reply. However, the sources you gave do not seem to apply exactly to my situation. I have attached some screenshots that show what the dialogue box looks like for a pdf download, and what my settings in the Apps panel of Options are. You will note in the first screenshot that I have checked the box to handle this file type automatically; however, the next time I try to download a file of that type, the same dialogue box appears looking exactly like the one shown, so checking the "automatic" option appears to do nothing. The files to be downloaded from my Gmail messages are not generic or altered file types - they are shown as pdf, doc, docx, etc. So while your intent was good, your post did not help. Thanks anyway.

  • IPad 2 6.1.3 iMessage not consistently working. Has trouble sending and receiving. How can this be fixed?

    iPad 2 6.1.3 iMessage not consistently working. Has trouble sending and receiving. How can this be fixed? Have tried restarting, turning iMessage off and on, signing out and in. Please help, thanks!

    Using FaceTime http://support.apple.com/kb/ht4319
    Troubleshooting FaceTime http://support.apple.com/kb/TS3367
    The Complete Guide to FaceTime + iMessage: Setup, Use, and Troubleshooting
    http://tinyurl.com/a7odey8
    Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/TS4268
    iOS: FaceTime is 'Unable to verify email because it is in use'
    http://support.apple.com/kb/TS3510
    Using FaceTime and iMessage behind a firewall
    http://support.apple.com/kb/HT4245
    iOS: About Messages
    http://support.apple.com/kb/HT3529
    Set up iMessage
    http://www.apple.com/ca/ios/messages/
    iOS 6 and OS X Mountain Lion: Link your phone number and Apple ID for use with FaceTime and iMessage
    http://support.apple.com/kb/HT5538
    How to Set Up & Use iMessage on iPhone, iPad, & iPod touch with iOS
    http://osxdaily.com/2011/10/18/set-up-imessage-on-iphone-ipad-ipod-touch-with-io s-5/
    Troubleshooting Messages
    http://support.apple.com/kb/TS2755
    Troubleshooting iMessage Issues: Some Useful Tips You Should Try
    http://www.igeeksblog.com/troubleshooting-imessage-issues/
    Setting Up Multiple iOS Devices for iMessage and Facetime
    http://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htm l
    FaceTime and iMessage not accepting Apple ID password
    http://www.ilounge.com/index.php/articles/comments/facetime-and-imessage-not-acc epting-apple-id-password/
    FaceTime, Game Center, Messages: Troubleshooting sign in issues
    http://support.apple.com/kb/TS3970
    Unable to use FaceTime and iMessage with my apple ID
    https://discussions.apple.com/thread/4649373?tstart=90
    How to Block Someone on FaceTime
    http://www.ehow.com/how_10033185_block-someone-facetime.html
    My Facetime Doesn't Ring
    https://discussions.apple.com/message/19087457
    To send messages to non-Apple devices, check out the TextFree app https://itunes.apple.com/us/app/text-free-textfree-sms-real/id399355755?mt=8
    How to Send SMS from iPad
    http://www.iskysoft.com/apple-ipad/send-sms-from-ipad.html
    You can check the status of the FaceTime/iMessage servers at this link.
    http://www.apple.com/support/systemstatus/
     Cheers, Tom

  • Since 2012 I have Photoshop Elements always worked without any problem, however now the language is suddenly German how can this be changed, removed the program and re-installed, not working. Program is downloaded and updated via the apple app store?

    Since 2012 I have Photoshop Elements always worked without any problem, however now the language is suddenly German how can this be changed, removed the program and re-installed, not working. Program is downloaded and updated via the apple app store?

    I've done some research on the SQLite database. Whenever Aperture hangs up (like during auto-stack or opening the filter hud) there are thousands of SQLite queries happening. These SQLite queries cause massive file I/O because the database is stored on the disk as 1kb pages. However, the OS is caching the database file; mine's only 12MB. I'm trying to track down some performance numbers for SQLite on osx but having trouble.
    It's starting to look like most of the speed problems are in the libraries that Aperture uses instead of the actual Aperture code. Of course, that doesn't completely let the developers off the hook since they choose to use them in the first place.
    Oh, and if anyone is curious, the database is completely open to queries using the command line sqlite3 tool. Here's the language reference http://www.sqlite.org/lang.html
    Hmm, just found this. Looks like someone else has been playing around in the db http://www.majid.info/mylos/stories/2005/12/01/apertureInternals.html
    Dual 1.8 G5   Mac OS X (10.4.3)   1GB RAM, Sony Artisan Monitor, Sony HC-1 HD Camera

  • Has anyone encountered drastic shorter battery life both on iphone 5 and ipad since updating to iOS 6.1.2? How can this problem be solved?

    Dear all,
    I am new to this community even though I have been a Apple user for years, so please forgive me if this question is not in the right section.
    Has anyone encountered drastic shorter battery life both on iphone 5 and ipad since updating to iOS 6.1.2? I've always been happy with these two products until the update - now the battery life is considerably shorter which is extremely frustrating.
    How can this problem be solved? Is there any way to go back to the previous version?
    Thanks for your help.

    If you update using iTunes the phone is first wiped clean, then the new OS is installed, and finally the backup is restored. After this finishes if you sync your music should be restored. Music is not in the backup, because it is already on your computer and duplicating it would use up a lot of hard disk space.
    An OTA update just patches what has changed; it does not disturb content.

  • After closing out, FF will not restart, says it is already running forcing me to reboot. I have removed and re-installed FF and still get the same message when trying to open the internet using FF. How can this be fixed?

    When I close out Firefox, and return later to use the internet, I click on Firefox and it gives me a message stating that Firefox is already running and needs to be closed before restarting or reboot my system. This occurs every time Firefox is closed and attempt to re-start it,,, not only at times,,,, EVERY time.
    I have tried removing Firefox from my system and re-installing to fix this issue however,,, this did not work. After re-installing, I still get the same message when attempting to restart Firefox.
    I have also tried Ctrl, Alt, delete to open the task manager and find there is no task to close.
    I do not have any problems when using IE, I prefer to use Firefox as it is faster and crashes less than IE.
    I am very frustrated at having to reboot my system each time I want to use the internet.
    How can this problem be repaired?

    There are various causes for this error, see [[Firefox is already running but is not responding]] for details.

  • I have an iPhone 4 still running 6.1.3 software.  A few days ago it stopped working through my car's USB connection.  How can this be fixed?

    I have an iPhone 4 still running 6.1.3 software.  A few days ago it stopped working through my car's USB connection (I have a 2010 Honda Civic Hybrid).  I can no longer control my music through my car's stereo system.  I am unable to choose what song, album, playlist, etc. to be played and cannot skip songs.  When I try to skip, it reverts back to the first song.  When I choose what to be played directly on my phone, it can only be played for about 30 seconds through my car's stereo system before it stops and displays the message "Unsupported Version."  How can this be fixed?  (Also, I know it is my iPhone and not my car because someone I know has the same exact car as me from 2009 and it did the same thing on theirs.)
    Any help would be greatly appreciated.  This problem is extremely frustrating and the alternative of trying to change music directly on my phone while driving is a risk I am not willing to consider.  Thanks!

    Alright, sorry for not having browsed this page a bit more before stating my question. I have just found some other similar topics on this problem. Please don't reply this thread unless there actually is a solution to the problem, because at current time there is not.

  • PSE 10 installed on windows 7 desktop and recently updated on windows laptop.  now PSE doesn't work on either machine.  How can this be fixed?

    PSE 10 installed on windows 7 desktop and recently updated on windows laptop.  now PSE doesn't work on either machine.  How can this be fixed?

    uninstall pse 10 (properly using the adobe uninstaller).
    clean - Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6
    then try reinstalling using the adobe installation file(s).
    if you see an activation count error while trying to reinstall contact adobe support, https://helpx.adobe.com/contact.html
    and ask for an activation count reset.

  • HT202853 I have many project made in move HD that are not updating to the new iMovie 10 on my new iMac.  Why is this not working as stated?  How do I get my projects back from backup after old iMac crashed?

    I have many projects made in imovie HD that are not updating to iMovie 10 on my new iMac.  Why is this not working as stated on the article HT202853?  How do I get my projects back from backup after old iMac crashed?

    According to:
    Update projects and events from previous versions of iMovie in iMovie (2014) - Apple Support
    you can update from iMovie versions 7, 8 and 9, but iMovie HD is iMovie 6.
    Maybe you can update in two steps, first from iMovie 6 to iMovie 7, 8 or 9 then to iMovie 10. 
    Geoff.

  • My 2 TB Time Capsule's memory is full because it will not automatically delete old files as it is supposed to, so it is giving me zero backup of my two computers now.  How can this be fixed so my Time Capsule deletes the old data and saves the new?

    My 2 TB Time Capsule’s memory is full because it will notautomatically delete old files as it is supposed to, so it is giving me zerobackup of my two computers now. How can this be fixed so my Time Capsule deletes the old data and savesthe new?
    Neither my local computer consultant nor I have been ableto change any of the settings in Time Machine to correct this problem.  Working with the choices in the TimeMachine, there does not appear that there is any way to change the frequency ofthe backups either, so, after a year has elapsed, the time capsule is full, andmy only choice appears to be to erase all the current data on the Time Capsuleand start over, something that I do not want to at all let alone repeat on anannual basis.  My questions are:
    What can be done to have my Time Capsule delete old filesas it is supposed to do, so it has memory available to allow my computers toback up? 
    Is this a software problem that can be fixed online or isdoes this require a mechanical fix of defective hardware?

    How much data is being backed-up from each Mac?  (see what's shown for Estimated size of full backup under the exclusions box in Time Machine Prefs > Options).
    Is there any other data on your Time Capsule, besides the backups?
    Most likely, there just isn't room.  Time Machine may be trying to do a very large (or full) backup of one or both Macs, and can't.  Since it won't ever delete the most recent backup, there has to be enough room for one full backup plus whatever it's trying to back up now, plus 20% (for workspace).
    Also see #C4 in Time Machine - Troubleshooting for more details.

  • I have done upgrade to 8.1.2. Now iPad a iPhone will will not connect to iTunes, iCloud or do updates on apps.Shows message "unable to connect" or "error in connecting"  as well as "unable to verify". How can this be sorted?

    I have done upgrade to 8.1.2. Now iPad a iPhone will will not connect to iTunes, iCloud or do updates on apps.Shows message "unable to connect" or "error in connecting"  as well as "unable to verify". How can this be sorted? Thanks

    Hi,
    Thanks.
    I have tried signing out and in, still does not work.
    Still just get the previously mentioned "messages".
    I wanted to restore, but then you have to turn off "find my ipad/iphone" but this is not allowed, as I cannot connect to the itunes/icloud or app store. The units work with current apps. EG; email etc, and with apps that do not require current updates.
    Thanks

  • ITunes randomly stops playing purchases that have previously viewed on the same hardware. It has an error message about HD. How can this issue be resolved?  What information is available besides the "learn more" option that does not deal with the problem?

    iTunes randomly stops playing purchases that have previously viewed on the same hardware. It has an error message about HD. How can this issue be resolved?  What information is available besides the "learn more" option that does not deal with the problem?
    Many people have the same problem. However, there is little or nothing readily available to users. This problem has existed for two or more years. Does anyone have anything to offer about this disturbing problem?

    Thanks for the suggestion kcell. I've tried both versions
    9.0.115 and 9.0.124 and both fail with the policy permission error.
    I also tried with and without your crossdomain.xml file but
    with the same result. It looks like this file is intended for URL
    policy, instead of socket policy. Recently Adobe separated the two.
    When I run with the files installed on my dev PC, it does
    work, which makes sense because the flash player isn't loaded from
    an unknown domain.
    I did get one step closer. If a crossdomain.xml in the server
    root exists and the socketpolicy file is loaded from the app folder
    then the first two warnings disappear. The logs now show:
    OK: Root-level SWF loaded:
    https://192.168.2.5/trunk/myapp.swf
    OK: Policy file accepted: https://192.168.2.5/crossdomain.xml
    OK: Policy file accepted:
    https://192.168.2.5/trunk/socketpolicy.xml
    Warning: Timeout on xmlsocket://192.168.2.5:843 (at 3
    seconds) while waiting for socket policy file. This should not
    cause any problems, but see
    http://www.adobe.com/go/strict_policy_files
    for an explanation.
    Warning: [strict] Ignoring policy file with incorrect syntax:
    xmlsocket://192.168.2.5:993
    Error: Request for resource at xmlsocket://192.168.2.5:993 by
    requestor from https://192.168.2.5/trunk/myapp.swf is denied due to
    lack of policy file permissions.
    Which basically says, everything is okay, but you stay out
    anyway.
    PS: I found the XML schema files here:
    http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security_02.html
    and the socket policy schema:
    http://www.adobe.com/xml/schemas/PolicyFileSocket.xsd.
    UPDATE: When serving up the policy file on port 843 using the
    example perl script then the socket connection seems to be accepted
    and the connect succeeds. After that flex hangs trying to logon to
    the IMAP server.

Maybe you are looking for

  • How do you retrieve the value?

    Hi There, XML request is: <?xml version="1.0" encoding="utf-8"?> <payload>   <region>     <__type>Category:#Test.XYZ.Framework.Categorization</__type>     <Extension></Extension>     <Id></Id>     <Name>       <en></en>        </Name>      </region>

  • Arabic Text with SKR Headr1 Font

    I have installed Indesign CC, Added New Arabic Text with SKR Headr1 Font, but arabic text is scrambled, Tried with CS5/6, same issue, I Have i7-Win7x64 Arabic Enabled

  • Specific problem with trackpad

    I have this specific problem with my trackpad, it doesnt work this 2 functions:  Swipe between pages and scroll direction: natural. all other functions are working. i don't know what to do .

  • How to do debugging for a batch job?

    Hi Colleague, I created a batch job via t-code sm36 in SAP GUI, and added a report to this batch job, there is no problem to run this report directly, but fails to run the batch job. How can I do debugging for this batch job? Kind Regards Andie

  • Download 11g Linux x86 doesn't work

    404 page not found when i try to download database 11g for Linux x86. In addition, other downloads (e.g. 10g) are very slow. Like 10-30Kb/s !!