Find the answer to your Linux question:
Page 2 of 4 FirstFirst 1 2 3 4 LastLast
Results 11 to 20 of 33
Ok I issued the same commands on the test directory on my external drive; which incidentally is named "SignatureMini" Still got a broken symlink that points to the same place. ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Just Joined!
    Join Date
    Nov 2010
    Location
    Philippines
    Posts
    29

    Ok I issued the same commands on the test directory on my external drive; which incidentally is named "SignatureMini"

    Still got a broken symlink that points to the same place.

    "/home/scribe/.wine/drive_c/I/Tim/GOTTCHA Bus. Serv/Gott it Dunn/Admin/Legal Department"

    And I've only been on Ubuntu for about a month now so I am deducing that I need to figure out how to "mount"? my "SignatureMini" as "/drive_c/" somehow in wine?

    I'll start googling on that now. But I'll check back here from time to time to see if I get a tip from you before I figure it out. Thanks again this looks like real progress.

  2. #12
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by tg3793 View Post
    Ok I issued the same commands on the test directory on my external drive; which incidentally is named "SignatureMini"

    Still got a broken symlink that points to the same place.

    "/home/scribe/.wine/drive_c/I/Tim/GOTTCHA Bus. Serv/Gott it Dunn/Admin/Legal Department"

    And I've only been on Ubuntu for about a month now so I am deducing that I need to figure out how to "mount"? my "SignatureMini" as "/drive_c/" somehow in wine?

    I'll start googling on that now. But I'll check back here from time to time to see if I get a tip from you before I figure it out. Thanks again this looks like real progress.

    The script is for sure buggy and makes some assumptions. I don't remember when did I write it, but it was just a quick hack and it might assume some paths. I can look at it. But, can you -please- paste the output for this command without -d?

    Code:
    ./lnk2symlink <directory containing lnk files>

  3. #13
    Just Joined!
    Join Date
    Nov 2010
    Location
    Philippines
    Posts
    29
    Quote Originally Posted by i92guboj View Post
    Can you -please- paste the output for this command without -d?

    Code:
    ./lnk2symlink <directory containing lnk files>

    Gotcha.

    ./lnk2symlink test
    Specified directory: test
    Finding files, this may take a while...

    Processing file: test/Legal Department.lnk
    ================================================== ==============================
    This is what WOULD be done:
    ln -s /home/scribe/.wine/drive_c/I/Tim/GOTTCHA Bus. Serv/Gott it Dunn/Admin/Legal Department test/Legal Department


    Incidentally my SignatureMini used to be drive "g:/" in my windows environment so I just created a drive g: under WINE and pointed it to the SignatureMini. However as I'm sure you already knew that didn't help matters any :-)

  4. $spacer_open
    $spacer_close
  5. #14
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Strange, there should be two paths in there and I can see only one. Can you modify the first line of the script, with a text editor, to make it look like this?

    Code:
    #!/bin/bash -x
    Then run again without -d and post the output? That should give us some debug info.

  6. #15
    Just Joined!
    Join Date
    Nov 2010
    Location
    Philippines
    Posts
    29
    Ok, changed the first line of the script and now it's spitting out plenty:

    $ ./lnk2sym test
    + VERSION=20101210
    ++ basename ./lnk2sym
    + PROGRAM_NAME=lnk2sym
    + DELETE_LNK=0
    + case $1 in
    + DO_WORK=0
    + DIR=test
    + TEST_FILE=test/test-6472165187017278
    + ln -s /home/scribe test/test-6472165187017278
    + rm -f test/test-6472165187017278
    + echo 'Specified directory: test'
    Specified directory: test
    + echo 'Finding files, this may take a while...'
    Finding files, this may take a while...
    + find test -iname '*.lnk'
    + read LNK_FILE
    + echo

    + echo 'Processing file: test/Legal Department.lnk'
    Processing file: test/Legal Department.lnk
    + echo ================================================== ==============================
    ================================================== ==============================
    ++ grep ':\\'
    ++ strings 'test/Legal Department.lnk'
    + CANDIDATE_STRING='/G:\
    G:\I\Tim\GOTTCHA Bus. Serv\Gott it Dunn\Admin\Legal Department'
    ++ sed -e 's#.*\:\\#/home/scribe\/.wine\/drive_c\/#'
    ++ echo '/G:\' 'G:\I\Tim\GOTTCHA' Bus. 'Serv\Gott' it 'Dunn\Admin\Legal' Department
    ++ sed -e 's#\\#\/#g'
    + LINUX_PATH='/home/scribe/.wine/drive_c/I/Tim/GOTTCHA Bus. Serv/Gott it Dunn/Admin/Legal Department'
    + SYMLINK_NAME='test/Legal Department'
    + '[' '!' -L 'test/Legal Department' ']'
    + '[' -r 'test/Legal Department' ']'
    + '[' 0 -eq 1 ']'
    + echo 'This is what WOULD be done:'
    This is what WOULD be done:
    + echo 'ln -s /home/scribe/.wine/drive_c/I/Tim/GOTTCHA Bus. Serv/Gott it Dunn/Admin/Legal Department test/Legal Department'
    ln -s /home/scribe/.wine/drive_c/I/Tim/GOTTCHA Bus. Serv/Gott it Dunn/Admin/Legal Department test/Legal Department
    + '[' 0 -eq 1 ']'
    + read LNK_FILE


    Oh don't let the name of the command throw you. I shorted it to lnk2sym

  7. #16
    Just Joined!
    Join Date
    Nov 2010
    Location
    Philippines
    Posts
    29
    ok I am SOOO supra novice. But I'm willing to look at the code and learn. I'm guessing the following as something to do with the "/.wine/drive_c" being chosen?

    ++ sed -e 's#.*\:\\#/home/scribe\/.wine\/drive_c\/#'
    ++ echo '/G:\' 'G:\I\Tim\GOTTCHA' Bus. 'Serv\Gott' it 'Dunn\Admin\Legal' Department
    ++ sed -e 's#\\#\/#g'


    And that there needs to be some sort of "if" statement regarding some sort of discovery technique or "polling" technique?

    Please don't consider this a recommendation. Just consider it a guy poking at the problem trying to figure out things to the point where he can help or even possibly "do" them one day :-)

  8. #17
    Just Joined!
    Join Date
    Nov 2010
    Location
    Philippines
    Posts
    29
    I feel so stupid :-/ ... And I probably have you banging your head against a problem for no reason at all. This is one of those "I can't see the forest for the trees" issues. I am very sorry and 'do' appreciate your help on this.

    Ok you ready?

    I get a shortcut to the WINE drive c when I run this script on a test directory that I've copied to sda1. But then I run it on my external drive; which just happens to be NTFS duh.

    But tis true that I didn't get the error message that I would have expected which would have been "The target filesystem doesn't support symlinks."

    I have a another external that I'll format to Ext4 or some other compatible FileSystem tomorrow. I'll have to go pick up my wife in a few minutes and then the evening family routing will begin.

    Thank you yet again.

  9. #18
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by tg3793 View Post
    I feel so stupid :-/ ... And I probably have you banging your head against a problem for no reason at all. This is one of those "I can't see the forest for the trees" issues. I am very sorry and 'do' appreciate your help on this.
    Don't worry. It took me long to answer because I was busy with work and personal matters. You are trying to do something at least, that's more than most newcomers do. So you are doing very well.

    I get a shortcut to the WINE drive c when I run this script on a test directory that I've copied to sda1. But then I run it on my external drive; which just happens to be NTFS duh.
    The destination fs, as you already guessed, needs to be compatible with symlinks. NTFS is not (FAT isn't either).

    But tis true that I didn't get the error message that I would have expected which would have been "The target filesystem doesn't support symlinks."
    Probably some problem with the logic in the script. I will test this if I get the time and clean it a bit. It seems messy to be such a simple tool.

    I have a another external that I'll format to Ext4 or some other compatible FileSystem tomorrow. I'll have to go pick up my wife in a few minutes and then the evening family routing will begin.
    You can look into loopback filesystems. You can create a file full of zeroes (using dd if=/dev/zero of=file.img, look the bs and count dd options), then format the file (yes, the file) as ext4, mount it with mount -o loop, and then copy the files in there to make your tests without having to format a partition or a disk.


    Code:
    #!/bin/bash
    
    ######################################################################
    #                                                                    #
    # lnk2symlink by jesus.guerrero.botella at gmail dot com,            #
    # search for windows .lnk files on a given directory, and creates    #
    # symlinks according to the info contained on those files            #
    #                                                                    #
    # This script is provided without any kind of implicit or explicit   #
    # guarantee, and is licensed under the GNU General Public License v3 #
    # or later if available. More about licenses on the following URL:   #
    #                                                                    #
    # http://www.gnu.org/licenses/licenses.html                          #
    #                                                                    #
    ######################################################################
    
    VERSION=20101213
    PROGRAM_NAME=$(basename $0)
    DELETE_LNK=0
    
    die() {
    	case $1 in
    		non_linkable_fs)
    			echo "The target filesystem doesn't support symlinks."
    			exit 11
    			;;
    		ln_error)
    			echo "Undefined error while symlinking."
    			exit 10
    			;;
    		*)
    			echo "Undefined error."
    			exit 20
    			;;
    	esac
    }
    
    show_help() {
    		echo "$PROGRAM_NAME v$VERSION"
    		echo "Search for windows .lnk files and creates linux symlinks according"
    		echo "to the info within those .lnk files."
    		echo
    		echo "Usage: "
    		echo "    $PROGRAM_NAME [-d|--do] [directory]"
    		echo
    		echo "Where the optional parameter [directory] is a directory where to look"
    		echo "for .lnk files, and -d|--do is a parameter to actually do the work."
    		echo "By default, $PROGRAM_NAME will not do anything, but just output WHAT"
    		echo "would be done if -d|--do is used."
    		echo 
    		echo "Parameters:"
    		echo "  -d, --do"
    		echo "    Do the real work."
    		echo "  -h, --help"
    		echo "    Show this help text."
    		echo "  -e, --erase, --del, --delete"
    		echo "    Delete de .lnk files after doing the work. These imply --do."
    		echo
    }
    
    case $1 in
    	-h|--help|"")
    		show_help
    		exit 0
    		;;
    	-d|--do)
    		DO_WORK=1
    		DIR="$2"
    		;;
    	-e|--erase|--del|--delete)
    		DELETE_LNK=1
    		DO_WORK=1
    		DIR="$2"
    		;;
    	*)
    		DO_WORK=0
    		DIR="$1"
    		;;
    esac
    
    TEST_FILE="$DIR/test-$RANDOM$RANDOM$RANDOM$RANDOM"
    ln -s "$HOME" "$TEST_FILE" > /dev/null 2>&1 || die non_linkable_fs
    rm -f "$TEST_FILE"
    
    echo "Specified directory: $DIR"
    echo "Finding files, this may take a while..."
    find "$DIR" -iname '*.lnk' | while read LNK_FILE
    do
    	echo
    	echo "Processing file: \"$LNK_FILE\""
    	CANDIDATE_STRING=$(strings "$LNK_FILE" | grep ':\\')
    	LINUX_PATH="$(echo $CANDIDATE_STRING | \
    		sed -e 's#.*\:\\#'"$HOME"'\/.wine\/drive_c\/#' | \
    		sed -e 's#\\#\/#g')"
    	SYMLINK_NAME="${LNK_FILE/.lnk/}"
    	if [ ! -L "$SYMLINK_NAME" ]
    	then
    		if [ -r "$SYMLINK_NAME" ]
    		then
    			echo "File with the same name detected, but it's not a symlink."
    			echo "I will add a RANDOM suffix to the symlink name."
    			SYMLINK_NAME="${SYMLINK_NAME}-${RANDOM}"
    		fi
    		if [ $DO_WORK -eq "1" ]
    		then
    			echo "Running: ln -s \"$LINUX_PATH\" \"$SYMLINK_NAME\""
    			ln -s "$LINUX_PATH" "$SYMLINK_NAME" || die
    		else
    			echo "This is what WOULD be done:"
    			echo "ln -s \"$LINUX_PATH\" \"$SYMLINK_NAME\""
    		fi
    	else
    		echo "\"$SYMLINK_NAME\" do exist, and it's a symlink, skipping."
    	fi
    	if [ $DELETE_LNK -eq "1" ]
    	then
    		rm -f "$LNK_FILE"
    	fi
    done
    This revision has better quoting for paths which will probably help in the future when looking at the output.

  10. #19
    Just Joined!
    Join Date
    Nov 2010
    Location
    Philippines
    Posts
    29
    Ok, wife was running late so I was able to format the drive to ext4 and then copy four of the shortcuts over. I don't think I'll have time to try your new script tonight though.

    However with that first script I have the same problem; everything pointing to "/.wine/drive_c".

    Using the same instructions as before with "#!/bin/bash -x" at the top, this is what I got.

    $ ./lnk2sym _shortcuts
    + VERSION=20101210
    ++ basename ./lnk2sym
    + PROGRAM_NAME=lnk2sym
    + DELETE_LNK=0
    + case $1 in
    + DO_WORK=0
    + DIR=_shortcuts
    + TEST_FILE=_shortcuts/test-898840023031126625
    + ln -s /home/scribe _shortcuts/test-898840023031126625
    + rm -f _shortcuts/test-898840023031126625
    + echo 'Specified directory: _shortcuts'
    Specified directory: _shortcuts
    + echo 'Finding files, this may take a while...'
    Finding files, this may take a while...
    + find _shortcuts -iname '*.lnk'
    + read LNK_FILE
    + echo

    + echo 'Processing file: _shortcuts/Personal New.Proj (on I).lnk'
    Processing file: _shortcuts/Personal New.Proj (on I).lnk
    + echo ================================================== ==============================
    ================================================== ==============================
    ++ strings '_shortcuts/Personal New.Proj (on I).lnk'
    ++ grep ':\\'
    + CANDIDATE_STRING='/G:\
    G:\I\Tim\Personal\Proj\New.Proj'
    ++ sed -e 's#.*\:\\#/home/scribe\/.wine\/drive_c\/#'
    ++ echo '/G:\' 'G:\I\Tim\Personal\Proj\New.Proj'
    ++ sed -e 's#\\#\/#g'
    + LINUX_PATH=/home/scribe/.wine/drive_c/I/Tim/Personal/Proj/New.Proj
    + SYMLINK_NAME='_shortcuts/Personal New.Proj (on I)'
    + '[' '!' -L '_shortcuts/Personal New.Proj (on I)' ']'
    + '[' -r '_shortcuts/Personal New.Proj (on I)' ']'
    + '[' 0 -eq 1 ']'
    + echo 'This is what WOULD be done:'
    This is what WOULD be done:
    + echo 'ln -s /home/scribe/.wine/drive_c/I/Tim/Personal/Proj/New.Proj _shortcuts/Personal New.Proj (on I)'
    ln -s /home/scribe/.wine/drive_c/I/Tim/Personal/Proj/New.Proj _shortcuts/Personal New.Proj (on I)
    + '[' 0 -eq 1 ']'
    + read LNK_FILE
    + echo

    + echo 'Processing file: _shortcuts/Tech TOOLS_General (on J).lnk'
    Processing file: _shortcuts/Tech TOOLS_General (on J).lnk
    + echo ================================================== ==============================
    ================================================== ==============================
    ++ grep ':\\'
    ++ strings '_shortcuts/Tech TOOLS_General (on J).lnk'
    + CANDIDATE_STRING='/G:\
    G:\J\Installs\- Blip 01\Tech\TOOLS (General)'
    ++ sed -e 's#.*\:\\#/home/scribe\/.wine\/drive_c\/#'
    ++ echo '/G:\' 'G:\J\Installs\-' Blip '01\Tech\TOOLS' '(General)'
    ++ sed -e 's#\\#\/#g'
    + LINUX_PATH='/home/scribe/.wine/drive_c/J/Installs/- Blip 01/Tech/TOOLS (General)'
    + SYMLINK_NAME='_shortcuts/Tech TOOLS_General (on J)'
    + '[' '!' -L '_shortcuts/Tech TOOLS_General (on J)' ']'
    + '[' -r '_shortcuts/Tech TOOLS_General (on J)' ']'
    + '[' 0 -eq 1 ']'
    + echo 'This is what WOULD be done:'
    This is what WOULD be done:
    + echo 'ln -s /home/scribe/.wine/drive_c/J/Installs/- Blip 01/Tech/TOOLS (General) _shortcuts/Tech TOOLS_General (on J)'
    ln -s /home/scribe/.wine/drive_c/J/Installs/- Blip 01/Tech/TOOLS (General) _shortcuts/Tech TOOLS_General (on J)
    + '[' 0 -eq 1 ']'
    + read LNK_FILE
    + echo

    + echo 'Processing file: _shortcuts/Videos_Faith (on J).lnk'
    Processing file: _shortcuts/Videos_Faith (on J).lnk
    + echo ================================================== ==============================
    ================================================== ==============================
    ++ strings '_shortcuts/Videos_Faith (on J).lnk'
    ++ grep ':\\'
    + CANDIDATE_STRING='/G:\
    G:\J\Videos\Faith'
    ++ sed -e 's#\\#\/#g'
    ++ sed -e 's#.*\:\\#/home/scribe\/.wine\/drive_c\/#'
    ++ echo '/G:\' 'G:\J\Videos\Faith'
    + LINUX_PATH=/home/scribe/.wine/drive_c/J/Videos/Faith
    + SYMLINK_NAME='_shortcuts/Videos_Faith (on J)'
    + '[' '!' -L '_shortcuts/Videos_Faith (on J)' ']'
    + '[' -r '_shortcuts/Videos_Faith (on J)' ']'
    + '[' 0 -eq 1 ']'
    + echo 'This is what WOULD be done:'
    This is what WOULD be done:
    + echo 'ln -s /home/scribe/.wine/drive_c/J/Videos/Faith _shortcuts/Videos_Faith (on J)'
    ln -s /home/scribe/.wine/drive_c/J/Videos/Faith _shortcuts/Videos_Faith (on J)
    + '[' 0 -eq 1 ']'
    + read LNK_FILE


    Continued gratitude.

    And BTW. I'm a newcomer to Ubuntu but not a newcomer to tech. Been one of the latter for about sixteen years :-) Started out in DOS, Win3.x all the way until I stopped at XP Pro. Though I had a couple of short trials in Fedora before I become an Ubuntu convert.

  11. #20
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    No wonder, the path is hardcoded in a sed statement. I will redo this to be more generic.

Page 2 of 4 FirstFirst 1 2 3 4 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •