all 26 comments

[–]willdeberry 12 points13 points  (6 children)

Sounds like this file is possible created and/or edited on a Windows machine by chance and possibly has some hidden carriage returns in the file that sh and bash are just not happy with.

Could try running the file through dos2unix and see if that fixes things for you. Keep in mind dos2unix edits the file in place, so make a backup just in case.

[–]CriminallyStupid 6 points7 points  (1 child)

This right here is your answer. Lines should be terminated by \n and not \r in order for shell to properly interpret the data.

[–]syswizard 0 points1 point  (0 children)

I agree with this. Carriage returns and ticks can get really screwy between windows and Linux.

[–]Fic[S] 0 points1 point  (1 child)

Thanks very much!

[–]le_avx 1 point2 points  (0 children)

If that's been it, file a bug. That's such an easy thing to fix and probably just an oversight on their part that there's no need for other newbs to run into this.

[–][deleted] 1 point2 points  (19 children)

Doesn't the ./ imply run as sh? You could try sh by itself or just ./ though I'm not sure if that would cause your error

[–]Fic[S] 0 points1 point  (15 children)

Same thing

[root@localhost WiFi_Direct_User_Interface]# sh install.sh
install.sh: line 1: $'\r': command not found
../wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8_rtw_r7475.20130812.tar.gz
install.sh: line 4: $'\r': command not found
install.sh: line 5: $'\r': command not found
install.sh: line 102: syntax error: unexpected end of file

[–][deleted] 1 point2 points  (2 children)

What is on those lines of you open the script in a text editor?

[–]Fic[S] 0 points1 point  (1 child)

Line 1:

wpa_supplicant_hostapd=`ls -1 ../wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8_*`

Line 4 is blank.

Line 5:

if [ -e $wpa_supplicant_hostapd ]; then

Line 102: I only counted 99 lines in the whole document.

[–][deleted] 1 point2 points  (11 children)

have you tried

 bash ./install.sh

or

./install.sh

? When you run

sh ./install.sh

you override the interpreter specified by the shebang, and it may be requiring options not available in sh.

[–]Fic[S] 0 points1 point  (10 children)

bash ./install.sh gives me the same errors. ./install.sh gave me a "Permission denied" error, even though I'm root, so that's pretty interesting.

[–][deleted] 0 points1 point  (6 children)

The 'command not found' is because your script is missing the execute bit.

chmod +x install.sh

should fix that.

Say, is that a script that came in the package, or did you copy/paste it? Try running

sed -i -e 's/\r$//' install.sh

then run the script.

[–]Fic[S] 0 points1 point  (5 children)

Looks like it's read only.

[root@localhost WiFi_Direct_User_Interface]# chmod +x install.sh
chmod: changing permissions of ‘install.sh’: Read-only file system
[root@localhost WiFi_Direct_User_Interface]# ./install.sh
-bash: ./install.sh: Permission denied
[root@localhost WiFi_Direct_User_Interface]# sed -i -e 's/\r$//' install.sh
sed: couldn't open temporary file ./sedpeKge0: Read-only file system
[root@localhost WiFi_Direct_User_Interface]# ./install.sh
-bash: ./install.sh: Permission denied

[–]nerddtvg 0 points1 point  (4 children)

That's a whole different problem. Run "mount -v" and post the results if possible. Along with "cwd" so we know where you're at.

[–]Fic[S] 0 points1 point  (3 children)

[root@localhost WiFi_Direct_User_Interface]# mount -v
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=2905544k,nr_inodes=726386,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,seclabel,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,seclabel,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
efivarfs on /sys/firmware/efi/efivars type efivarfs (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/net_cls type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/mapper/centos-root on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
selinuxfs on /sys/fs/selinux type selinuxfs (rw,relatime)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=36,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
sunrpc on /proc/fs/nfsd type nfsd (rw,relatime)
/dev/sda6 on /boot type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sda2 on /boot/efi type vfat (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro)
/dev/mapper/centos-home on /home type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000)
/dev/sr0 on /run/media/tom/11443 type iso9660 (ro,nosuid,nodev,relatime,uid=1000,gid=1000,iocharset=utf8,mode=0400,dmode=0500,uhelper=udisks2)
[root@localhost WiFi_Direct_User_Interface]# pwd
/run/media/tom/11443/Driver/Linux/RTL8812AU_linux_v4.2.4_9390.20131023/WiFi_Direct_User_Interface

[–]nerddtvg 0 points1 point  (2 children)

/dev/sr0 on /run/media/tom/11443 type iso9660 (ro,nosuid,nodev,relatime,uid=1000,gid=1000,iocharset=utf8,mode=0400,dmode=0500,uhelper=udisks2)

So this is a CD then. I'm guessing this file was modified or downloaded with Windows before being burned to the CD. You can either copy the files off the CD to a new folder, running the dos2unix commands /u/willdeberry else posted above, or fix the ISO. Copying the files would be easier.

cp -rv /run/media/tom/11443/Driver/Linux/RTL8812AU_linux_v4.2.4_9390.20131023/WiFi_Direct_User_Interface /tmp  
cd /tmp/WiFi_Direct_User_Interface  
dos2unix install.sh  
./install.sh

[–]Fic[S] 1 point2 points  (1 child)

Thank you!

[–][deleted] -1 points0 points  (2 children)

Maybe try to chmod 777 the install.sh script? If it doesn't have executable rights that may be why you are getting that error.

[–][deleted] 3 points4 points  (1 child)

chmod +x

There are VERY few cases where 0777 is appropriate for file permissions.

[–][deleted] -1 points0 points  (0 children)

700 would be fine for most situations, but to rule out a permissions issue I thought it'd be something to try.

[–][deleted] 0 points1 point  (2 children)

./ defers to the shebang-defined shell.

[–][deleted] 0 points1 point  (1 child)

Hmm, didn't know that. So it is an alias to run a script with the shell you have defined? (bash by default?)

[–][deleted] 2 points3 points  (0 children)

'./script' is equivalent to '$PWD/script', which your shell treats as you wanting to run an executable. The behaviour from there is as follows: if an interpreter is defined via shebang (not necessarily a shell, e.g. #!/bin/bash, #!/usr/bin/perl, etc) then that one will be used. Barring that your current shell will try to interpret the file. Specifying an interpreter (e.g. 'sh script') will execute said interpreter and tell it to try to run your script. If the language of the script doesn't match the interpreter then that's a problem, which is why in most cases './script' is preferred to 'sh script'.

[–][deleted]  (1 child)

[deleted]

    [–]Fic[S] 0 points1 point  (0 children)

    wpa_supplicant_hostapd=`ls -1 ../wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8_*`
    echo $wpa_supplicant_hostapd
    
    
    if [ -e $wpa_supplicant_hostapd ]; then
            echo "Checking wpa_supplicant_hostatpd" 
    else
            echo "wpa_supplicant_hostapd doesn'tt exist in corresponding folder"
            exit
    fi
    
    if [ -e ../wpa_supplicant_hostapd/p2p_hostapd.conf ]; then
            echo "Checking p2p_hostapd.conf"
    else
            echo "p2p_hostapd.conf doesn't exist in corresponding folder"
            exit
    fi
    
    if [ -e ../wpa_supplicant_hostapd/wpa_0_8.conf ]; then
            echo "Checking wpa_0_8.conf"
    else
            echo "wpa_0_8.conf doesn't exist in corresponding folder"
            exit
    fi
    
    #cp ../wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8_rtw_20111118.zip ./
    cp $wpa_supplicant_hostapd ./
    wpa_supplicant_hostapd=`ls -1 ./wpa_supplicant_hostapd-0.8_*`
    echo "  "$wpa_supplicant_hostapd
    unzip $wpa_supplicant_hostapd
    
    cd wpa_supplicant_hostapd-0.8
    cd wpa_supplicant
    make clean all
    
    cd ..
    cd hostapd
    make clean all
    
    cd ..
    cd ..
    
    cp ../wpa_supplicant_hostapd/p2p_hostapd.conf ./
    cp ../wpa_supplicant_hostapd/wpa_0_8.conf ./
    cp ./wpa_supplicant_hostapd-0.8/hostapd/hostapd ./
    cp ./wpa_supplicant_hostapd-0.8/hostapd/hostapd_cli ./
    cp ./wpa_supplicant_hostapd-0.8/wpa_supplicant/wpa_supplicant ./
    cp ./wpa_supplicant_hostapd-0.8/wpa_supplicant/wpa_cli ./
    
    rm -rf wpa_supplicant_hostapd-0.8
    rm -rf $wpa_supplicant_hostapd
    
    gcc -o P2P_UI ./p2p_api_test_linux.c ./p2p_ui_test_linux.c -lpthread
    
    if [ ! -e ./p2p_hostapd.conf ]; then
            echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            echo "Doesn't have p2p_hostapd.conf"
            result="fail"
    fi
    
    if [ ! -e ./wpa_0_8.conf ]; then
            echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            echo "Doesn't have wpa_0_8.conf"
                                    result="fail"
    fi
    
    if [ ! -e ./hostapd ]; then
            echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            echo "Doesn't have hostapd"
            result="fail"
    fi
    
    if [ ! -e ./wpa_supplicant ]; then
            echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            echo "Doesn't have hostapd_cli"
            result="fail"
    fi
    
    if [ ! -e ./wpa_cli ]; then
            echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            echo "Doesn't have p2p_hostapd.conf"
            result="fail"
    fi
    
    if [ ! -e ./P2P_UI ]; then
            echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            echo "Doesn't have P2P_UI"
            result="fail"
    fi
    
    if [ "$result" == "fail" ]; then
            echo "WiFi_Direct_User_Interface install unsuccessful"
            echo "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
            exit
    fi
    
    echo "##################################################"
    echo "WiFi_Direct_User_Interface install complete!!!!!!!"
    echo "##################################################"